HP Forums

Full Version: (49G) Moser de Bruijn Sequence, OEIS A000695
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For integer input N the programme returns the Nth element of the sequence

http://oeis.org/A000695

ie the binary base representation of N read as a quaternary base number.

Code:

::
  CK1&Dispatch
  # FF
  ::
    FPTR2 ^DupQIsZero?
    ?SEMI
    Z0_
    SWAP
    FPTR2 ^Z>ZH
    FPTR2 ^ZBits
    ZERO_DO
    SWAP
    Z4_
    FPTR2 ^RMULText
    SWAP
    ISTOP-INDEX
    #1-
    FPTR2 ^ZBit?
    IT
    ::
      SWAP
      Z1_
      FPTR2 ^RADDext
      SWAP
    ;
    LOOP
    DROP
  ;
;
Reference URL's