HP Forums

Full Version: (50G) Stern's Diatomic Series
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
;
;
Reference URL's