Post Reply 
(50G) Stern's Diatomic Series
03-19-2015, 07:33 AM (This post was last modified: 06-15-2017 01:37 PM by Gene.)
Post: #1
(50G) Stern's Diatomic Series
For positive integer input N the programme returns the Nth element of the series

http://oeis.org/A002487

::
CK1&Dispatch
# FF
::
FPTR2 ^DupQIsZero?
?SEMI
Z0_
Z1_
ROT
FPTR2 ^Z>ZH
FPTR2 ^ZBits
ZERO_DO
INDEX@
FPTR2 ^ZBit?
ITE
::
ROT
3PICK
FPTR2 ^QAdd
3UNROLL
;
::
SWAP3PICK
FPTR2 ^QAdd
SWAP
;
LOOP
2DROP
;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)