HP Forums
(50G) Stern's Diatomic Series - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (50G) Stern's Diatomic Series (/thread-3425.html)



(50G) Stern's Diatomic Series - Gerald H - 03-19-2015 07:33 AM

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
;
;