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.

Showing 1-2 of 2 results.

A065084 Smallest prime having alternating bit sum (A065359) equal to n.

Original entry on oeis.org

3, 7, 5, 0, 277, 1109, 0, 17749, 70997, 0, 1398037, 5526869, 0, 72701269, 357915989, 0, 5659514197, 22902297941, 0, 297784399189, 1465948394837, 0, 23456248042837, 89426945725781, 0, 1430831131612501, 6004798429418837, 0
Offset: 0

Views

Author

Robert G. Wilson v, Nov 09 2001

Keywords

Comments

Only 3d = 11b has an alternating sum of 0 and alternated sums of 3*k are impossible for primes.

Examples

			a(4)=277 since the smallest number having alternating bit sum n is (4^n-1)/3, which for n = 4 is 85. Because 85 =(1010101)2 is composite, the next number with alternating bit sum 4 is the prime (100010101)2 = 277. - _Washington Bomfim_, Jan 21 2011
		

Crossrefs

Programs

  • Mathematica
    f[n_] := (d = Reverse[ IntegerDigits[n, 2]]; l = Length[d]; s = 0; k = 1; While[k < l + 1, s = s - (-1)^k*d[[k]]; k++ ]; s); a = Table[ f[ Prime[n]], {n, 1, 10^6} ]; b = Table[0, {13} ];
    Do[ If[ a[[n]] > -1 && b[[a[[n]] + 1]] == 0, b[[a[[n]] + 1]] = Prime[n]], {n, 1, 10^6} ]; b
  • PARI
    M(n)={return((4^n - 1)/3 + 2^(2*n) - 2^(2*n-2))};
    T(n,k)={pow2=2^(2*n-2);k+=pow2; for(j=1,n-2,pow2/=4; k-=pow2;if(isprime(k),return(k),k+=pow2;)); return(k)};
    T2(n,k)={pow2=2; for(j=1,n, k+=pow2;if(isprime(k),return(k),k-=pow2; pow2*=4)); return(k)};
    print("0 3");print("1 7");print("2 5");print("3 0");for(n=4,127,if(n%3==0,print(n," 0"),k=M(n);if(isprime(k),print(n," ",k),k=T(n,k);if(isprime(k),print(n," ",k),k=T2(n,k);if(isprime(k),print(n," ",k),print("a(",n,") not found")))))) \\ Washington Bomfim, Jan 22 2011

Extensions

a(14)-a(27) from Washington Bomfim, Jan 21 2011

A184908 Let S_n be the set of the integers having alternating bit sum equal to -n. There are a(n) primes among the smallest 3n+5 odd numbers of S_n.

Original entry on oeis.org

1, 7, 5, 0, 7, 5, 0, 7, 10, 0, 6, 3, 0, 5, 9, 0, 7, 7, 0, 7, 9, 0, 5, 6, 0, 6, 7, 0, 10, 7, 0, 4, 5, 0, 11, 7, 0, 10, 9, 0, 9, 4, 0, 4, 8, 0, 2, 6, 0, 9, 5, 0, 10, 9, 0, 8, 6, 0, 4, 3, 0, 4, 11, 0, 9, 3, 0, 5, 8, 0, 6, 3, 0, 11, 7, 0, 6, 8, 0, 5, 6
Offset: 0

Views

Author

Washington Bomfim, Jan 27 2011

Keywords

Examples

			The smallest 3n+5 = 8 odd numbers of the set S_1 of the integers having alternating bit sum -1 are 11, 35, 41, 47, 59, 107, 131, and 137, so a(1)=7.
		

Crossrefs

Programs

  • Maple
    A065359 := proc(n) local dgs ; dgs := convert(n,base,2) ; add( -op(i,dgs)*(-1)^i,i=1..nops(dgs)) ; end proc:
    S := proc(n) local ads,k; ads := {} ; for k from 1 by 2 do if A065359(k) = -n then ads := ads union {k} ; end if; if nops(ads) = 3*n+5 then return ads; end if; end do: end proc:
    A184908 := proc(n) local ads,a,p; a := 0 ; for p in S(n) do if isprime(p) then a := a+1 ; end if; end do: a ; end proc:
    for n from 0 do print(A184908(n)); end do: # slow! R. J. Mathar, Feb 11 2011
  • PARI
    II()={i = (2/3)*(4^n-1) + 1 + 2^(2*n+1); if(isprime(i),an++)};
    III()={w = 2^(2*n+3); for(j=1, n+1, i += w; w /= 4; i -= w; if(isprime(i), an++ ))};
    IV()={i+=6; if(isprime(i), an++ ); w=4; for(j=1, n, i -= w; w *= 4; i += w; if(isprime(i), an++))};
    V()={i += 2^(2*n+4) - 2^(2*n+2); if(isprime(i),an++ );w = i + 2^(2*n+5) - 2^(2*n+4); i = w - 2^(2*n+3) - 2^(2*n+1); if(isprime(i),an++ );w = 2^(2*n+1);for(j=1, n,i += w; w /= 4; i -= w;if(isprime(i),an++ ))};
    print1("1, 7, ");for(n=2,80, an=0; II(); III(); IV(); V(); print1(an,", ")) \\ Washington Bomfim, Feb 06 2011
Showing 1-2 of 2 results.