A072762 n coded as binary word of length=n with k-th bit set iff k is prime (1<=k<=n), decimal value.
0, 1, 3, 6, 13, 26, 53, 106, 212, 424, 849, 1698, 3397, 6794, 13588, 27176, 54353, 108706, 217413, 434826, 869652, 1739304, 3478609, 6957218, 13914436, 27828872, 55657744, 111315488, 222630977, 445261954, 890523909, 1781047818, 3562095636, 7124191272
Offset: 1
Examples
a(6) = '011010' = (((0*2+1)*2+1)*2*2+1)*2 = 26. a(7) = '0110101' = (((0*2+1)*2+1)*2*2+1)*2*2+1 = 53. a(8) = '01101010' = ((((0*2+1)*2+1)*2*2+1)*2*2+1)*2 = 106.
Links
- Alois P. Heinz, Table of n, a(n) for n = 1..3323 (first 300 terms from T. D. Noe)
- Eric Weisstein's World of Mathematics, Prime Constant.
Programs
-
Haskell
a072762 n = foldl (\v d -> 2*v + d) 0 $ map a010051 [1..n] -- Reinhard Zumkeller, Sep 17 2011
-
Maple
a:= proc(n) option remember; `if`(n<2, 0, 2 * a(n-1) + `if`(isprime(n), 1, 0)) end: seq(a(n), n=1..40); # Alois P. Heinz, Jan 18 2011
-
Mathematica
a[1] = 0; a[n_] := a[n] = 2*a[n-1] + Boole[PrimeQ[n]]; Table[a[n], {n, 1, 31}] (* Jean-François Alcover, Jun 14 2013 *) nxt[{n_,a_}]:={n+1,Boole[PrimeQ[n+1]]+2a}; Transpose[NestList[nxt,{1,0},30]][[2]] (* Harvey P. Dale, Jan 07 2015 *)
-
PARI
an=0; print1(an,", "); for(n=2,31, an=2*an+isprime(n); print1(an,", ")) \\ Washington Bomfim, Jan 18 2011
-
PARI
a(n)=my(s=1,p=2);forprime(q=3,n,s=s<<(q-p)+1;p=q);s<<(n-p) \\ Charles R Greathouse IV, Jun 03 2013
Formula
a(1) = 0 and a(n) = a(n-1)*2 + A010051(n) for n>1.
a(n) = (1/2)*(pi(n) + Sum_{i=1..n} 2^(n-i)*pi(i)), where pi = A000720. - Ridouane Oudra, Aug 26 2019
a(n) = floor(c*2^n), where c = A051006 is the prime constant. - Lorenzo Sauras Altuzarra, Jan 03 2023
Comments