cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A100634 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.

This page as a plain text file.
%I A100634 #32 Feb 16 2025 08:32:55
%S A100634 0,2,6,6,22,22,86,86,86,86,1110,1110,5206,5206,5206,5206,70742,70742,
%T A100634 332886,332886,332886,332886,4527190,4527190,4527190,4527190,4527190,
%U A100634 4527190,272962646,272962646,1346704470,1346704470,1346704470,1346704470,1346704470
%N A100634 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 A100634 1 is not considered prime. If 1 were to be considered prime, each term would be incremented by 1.
%H A100634 T. D. Noe, <a href="/A100634/b100634.txt">Table of n, a(n) for n = 1..300</a>
%H A100634 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/LeastSignificantBit.html">Least Significant Bit</a>
%e A100634 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 A100634 a:= proc(n) option remember; `if`(n<2, 0,
%p A100634       a(n-1)+`if`(isprime(n), 2^(n-1), 0))
%p A100634     end:
%p A100634 seq(a(n), n=1..35);  # _Alois P. Heinz_, Apr 01 2024
%t A100634 Table[FromDigits[Reverse[Table[If[PrimeQ[k] == True, 1, 0], {k, 1, N}]], 2], {N, 1, 40}]
%t A100634 FoldList[Plus, If[PrimeQ[#], 2^#/2, 0] & /@ Range@40] (* _David Dewan_, Apr 01 2024 *)
%o A100634 (PARI) Sum(an)={ L=#binary(an)-1; k=2; s=0; pow2=2;
%o A100634 forstep(j=L, 2, -1,
%o A100634 if(isprime(k), s+=pow2);
%o A100634 k++; pow2*=2);
%o A100634 return(s) };
%o A100634   n=1; an=0;
%o A100634 while(an<=1346704470,
%o A100634   an+=Sum(an); print1(an,", "); n++;
%o A100634   while(!isprime(n), print1(an,", "); n++);
%o A100634   an=2^(n-1)
%o A100634 ) \\ _Washington Bomfim_, Jan 17 2011
%Y A100634 Cf. A000040, A080355, A080339, A072762.
%K A100634 nonn,base
%O A100634 1,2
%A A100634 Joseph Biberstine (jrbibers(AT)indiana.edu), Dec 02 2004