Post Reply 
(50g) OEIS A030302: Binary Champernowne Constant
07-20-2017, 05:31 PM
Post: #1
(50g) OEIS A030302: Binary Champernowne Constant
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
  ;
;
Find all posts by this user
Quote this message in a reply
07-21-2017, 03:16 PM
Post: #2
RE: (50g) OEIS A030302: Binary Champernowne Constant
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
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




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