(50g) OEIS A030302: Binary Champernowne Constant - 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) OEIS A030302: Binary Champernowne Constant (/thread-8706.html) (50g) OEIS A030302: Binary Champernowne Constant - Gerald H - 07-20-2017 05:31 PM For integer input N the programme returns the Nth digit of the binary Champernowne constant. For more info see: https://oeis.org/A030302 Code: ``` ::   CK1&Dispatch   BINT1   ::     %2     %LN     DUP     %2     %/     3PICK     %1-     %*     '     ID 0     TRUE     3PICK3PICK     '     DUP     '     %EXP     '     %*     '     %-     BINT6     SYMBN     3PICK     5PICK     DUP     % 500.     %<=     ITE     ::       %1+       %LN       DUP       % .0195       %*       %1+       %*       % .665       %*       % .04       %+     ;     ::       DUP       %4       %-       %LN       SWAP       %LN       %1       OVER       %1/       %-       SWAP       %LN       %*       %-     ;     NUMSOLVE     2DROP     SWAP     ?PURGE_HERE     SWAPDROPSWAP     %/     %1+     %CEIL     %2     OVER     %^     %2     OVER     5PICK     %+     %2     %-     4PICK     %MOD     4PICK     %-     %1+     %^     4UNROLL     ROT     %+     %1-     SWAP     %/     %1-     %CEIL     %*     %FLOOR     %2     %MOD   ; ;``` RE: (50g) OEIS A030302: Binary Champernowne Constant - Gerald H - 07-21-2017 03:16 PM If you're doubtful about the values returned by the programme above please compare with the programme below which for integer input N returns the first N digits of the binary Champernowne constant as an integer. Code: ``` ::   CK1&Dispatch   BINT1   ::     FPTR2 ^PUSHFLAGS_     DOBIN     COERCE     NULL\$     OVER     #1+_ONE_DO     INDEX@     DO>STR     BINT3     OVERLEN\$     #1-SUB\$     &\$     DUPLEN\$     3PICK     #>=_  That's PTR 3747D     IT     ExitAtLOOP     LOOP     BINT1     ROT     SUB\$     FPTR2 ^POPFLAGS_     FPTR2 ^S>Z   ; ;```