%I #31 Apr 01 2024 14:19:59
%S 0,2,6,6,22,22,86,86,86,86,1110,1110,5206,5206,5206,5206,70742,70742,
%T 332886,332886,332886,332886,4527190,4527190,4527190,4527190,4527190,
%U 4527190,272962646,272962646,1346704470,1346704470,1346704470,1346704470,1346704470
%N a(n) is the decimal equivalent of the binary number whose k-th least significant bit is 1 iff k is a prime number and k <= n.
%C 1 is not considered prime. If 1 were to be considered prime, each term would be incremented by 1.
%H T. D. Noe, <a href="/A100634/b100634.txt">Table of n, a(n) for n = 1..300</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/LeastSignificantBit.html">Least Significant Bit</a>
%e a(5) = 22 because the k-th least significant bits 1,2,3,4,5 are prime for 2,3,5 and not prime for 1,4. So k=1->0, k=2->1, k=3->1, k=4->0 and k=5->1 gives the bit sequence 10110, which is 2 + 4 + 16 = 22 in its decimal expansion.
%p a:= proc(n) option remember; `if`(n<2, 0,
%p a(n-1)+`if`(isprime(n), 2^(n-1), 0))
%p end:
%p seq(a(n), n=1..35); # _Alois P. Heinz_, Apr 01 2024
%t Table[FromDigits[Reverse[Table[If[PrimeQ[k] == True, 1, 0], {k, 1, N}]], 2], {N, 1, 40}]
%t FoldList[Plus, If[PrimeQ[#], 2^#/2, 0] & /@ Range@40] (* _David Dewan_, Apr 01 2024 *)
%o (PARI) Sum(an)={ L=#binary(an)-1; k=2; s=0; pow2=2;
%o forstep(j=L, 2, -1,
%o if(isprime(k), s+=pow2);
%o k++; pow2*=2);
%o return(s) };
%o n=1; an=0;
%o while(an<=1346704470,
%o an+=Sum(an); print1(an,", "); n++;
%o while(!isprime(n), print1(an,", "); n++);
%o an=2^(n-1)
%o ) \\ _Washington Bomfim_, Jan 17 2011
%Y Cf. A000040, A080355, A080339, A072762.
%K nonn,base
%O 1,2
%A Joseph Biberstine (jrbibers(AT)indiana.edu), Dec 02 2004