login
Write binary digits of numbers 1, 2, 3, ... in a string; sequence gives the prime indexed digits.
1

%I #9 Jun 29 2014 22:27:43

%S 1,0,1,0,1,1,1,0,0,0,0,0,1,1,1,0,1,0,0,0,0,1,1,1,0,1,1,0,1,0,1,0,0,0,

%T 0,0,1,1,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,0,

%U 0,1,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1,0,1,1,0,0,0,1,0,1,1,1,1,0,1,1,0,0,0,0

%N Write binary digits of numbers 1, 2, 3, ... in a string; sequence gives the prime indexed digits.

%e In 1 10 11 100 101 110 111 1000 ... the prime indexed digits are 1,0,1,0,1,1,1,0

%t almostNatural[n_, b_] := Block[{m = 0, d = n, i = 1, l, p}, While[m <= d, l = m; m = (b - 1) i*b^(i - 1) + l; i++]; i--; p = Mod[d - l, i]; q = Floor[(d - l)/i] + b^(i - 1); If[p != 0, IntegerDigits[q, b][[p]], Mod[q - 1, b]]]; Table[ almostNatural[n, 2], {n, Prime@ Range@ 105}] (* _Robert G. Wilson v_, Jun 29 2014 *)

%o (PARI) { x=1; xlc=0; xl=0; forprime (p=2,1000, fl=1; if (xlc>=p && xlc-xl<p, fl=0;print1(","xb[p-xlc+xl])); while (fl==1, xb=binary(x); xl=length(xb); xlc+=xl; if (xlc>=p && xlc-xl<p, fl=0;print1(","xb[p-xlc+xl])); x++)) }

%Y Cf. A007376, A033307, A113566.

%K nonn,base

%O 0,1

%A _Jon Perry_, Jun 17 2004