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