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.

A065085 Smallest prime having alternating bit sum (A065359) equal to -n, or 0 if no such prime exists.

Original entry on oeis.org

3, 2, 43, 0, 683, 2731, 0, 43691, 174763, 0, 2796203, 44608171, 0, 715827881, 715827883, 0, 114532461227, 183251938027, 0, 2931494136491, 2932031007403, 0, 187647836990123, 748400914639531, 0, 11446649052900011, 45786596211600043, 0
Offset: 0

Views

Author

Robert G. Wilson v, Nov 09 2001

Keywords

Examples

			The smallest number having alternating bit sum -n is (2/3)(4^n-1), which for n=4 is 170 = (10101010)2. The least odd number with alternating bit sum -4 is (10)2 || ( (10101010)2 + (1)2 ) = 683, which is prime, so a(4) = 683. - _Washington Bomfim_, Jan 27 2011
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Plus @@ (-(-1)^Range[Floor[Log2@n + 1]] Reverse@ IntegerDigits[n, 2]); a = Table[ f[ Prime[n]], {n, 1, 10^6} ]; b = Table[0, {12} ]; Do[ If[ a[[n]] < 1 && b[[ -a[[n]] + 1]] == 0, b[[ -a[[n]] + 1]] = Prime[n]], {n, 1, 10^6} ]; b
  • PARI
    II()={i = (2/3)*(4^n-1) + 1 + 2^(2*n+1); if(isprime(i),return(1)); return(0)};
    III()={w = 2^(2*n+3); for(j=1, n+1, i += w; w /= 4; i -= w; if(isprime(i),return(1))); return(0)};
    IV()={i+=6; if(isprime(i), return(1)); w=4; for(j=1, n, i -= w; w*=4; i+=w; if(isprime(i), return(1)));return(0)};
    V()={i += 2^(2*n+4) - 2^(2*n+2); if(isprime(i),return(1));w = i + 2^(2*n+5) - 2^(2*n+4); i = w - 2^(2*n+3) - 2^(2*n+1); if(isprime(i),return(1));w = 2^(2*n+1);for(j=1, n,i += w; w /= 4; i -= w;if(isprime(i),return(1) ));return(0)};
    print("0 3");print("1 2");for(n=2,117, if(II(),print(n," ",i), if(III(),print(n," ",i), if(IV(),print(n," ",i), if(V(),print(n," ",i),if(n%3==0,print(n," 0"),print(n," not found."))))))) \\ Washington Bomfim, Feb 06 2011

Extensions

a(13)-a(27) from Washington Bomfim, Jan 27 2011

A184907 Let S_n be the set of the integers having alternating bit sum equal to n. There are a(n) primes among the smallest 2n+1 numbers of S_n.

Original entry on oeis.org

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

Views

Author

Washington Bomfim, Jan 25 2011

Keywords

Comments

The smallest 2n+1 numbers in the set S_n are given by (4^(n+1)-1)/3 - (-2)^k for k in 0..2*n. - Andrew Howroyd, Dec 15 2024

Examples

			The smallest 2n+1 = 5 numbers of the set S_2 of the integers having alternating bit sum 2, are 5, 17, 20, 23, and 29, so a(2)=4.
		

Crossrefs

Programs

  • PARI
    II()={i = (4^n - 1)/3 - 2^(2*n-2) + 2^(2*n); if(isprime(i),an++)};
    III()={w = 2^(2*n-2); for(j=1, n-1, i += w; w /= 4; i -= w; if(isprime(i), an++;))};
    IV()={i+=3; if(isprime(i), an++); w=2; for(j=1, n-1, i -= w; w *= 4; i+=w; if(isprime(i),an++))};
    print1("0, 1, 4, ");for(n=3,80, an=0; II(); III(); IV(); print1(an,", ")) \\ Washington Bomfim, Jan 25 2011
    
  • PARI
    a(n)={my(m=(4^(n+1)-1)/3); sum(k=0, 2*n, isprime(bitxor(m,1<Andrew Howroyd, Dec 15 2024

Formula

a(n) = 0 for n == 0 (mod 3). - Andrew Howroyd, Dec 15 2024
Showing 1-2 of 2 results.