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-10 of 143 results. Next

A095018 a(n) is the number of primes p which have exactly n zeros and n ones when written in binary.

Original entry on oeis.org

1, 0, 2, 4, 17, 28, 189, 531, 1990, 5747, 23902, 76658, 291478, 982793, 3677580, 13214719, 49161612, 177190667, 664806798, 2443387945
Offset: 1

Views

Author

Antti Karttunen, Jun 01 2004

Keywords

Comments

a(n) is the number of terms in A066196 which lie between 2^(2n-1) and 2^2n inclusively.

Examples

			a(1) = 1 since only 2_10 = 10_2 satisfies the criterion;
a(2) = 0 since there is no prime between 4 and 16 which meets the criterion.
The only primes in the range ]2^5,2^6[ with equal numbers of ones and zeros in their binary expansion are 37 (in binary 100101) and 41 (in binary 101011) thus a(3)=2.
a(4) = 4 since 139, 149, 163 and 197 meet the criterion; etc.
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Block[{c = 0, p = NextPrime[2^(2n -1) -1], lmt = 2^(2n)}, While[p < lmt, If[DigitCount[p, 2, 1] == n, c++]; p = NextPrime@ p]; c]; Array[f, 17] (* K. D. Bajpai and Robert G. Wilson v, Jan 10 2017 *)
  • Python
    from itertools import combinations
    from sympy import isprime
    def A095018(n): return sum(1 for d in combinations((1<Chai Wah Wu, Jul 18 2025

Extensions

Edited by N. J. A. Sloane, Jan 16 2017
a(18)-a(20) from Amiram Eldar, Nov 21 2020

A095102 Odd primes p for which all sums Sum_{i=1..u} L(i/p) (with u ranging from 1 to (p-1)) are nonnegative, where L(i/p) is Legendre symbol of i and p, defined to be 1 if i is a quadratic residue (mod p) and -1 if i is a quadratic non-residue (mod p).

Original entry on oeis.org

3, 7, 11, 23, 31, 47, 59, 71, 79, 83, 103, 131, 151, 167, 191, 199, 239, 251, 263, 271, 311, 359, 383, 419, 431, 439, 479, 503, 563, 599, 607, 647, 659, 719, 743, 751, 839, 863, 887, 911, 919, 971, 983, 991, 1031, 1039, 1063, 1091, 1103, 1151
Offset: 1

Author

Antti Karttunen, Jun 01 2004

Keywords

Comments

All 4k+3 primes whose Legendre-vector (cf. A055094) forms a valid Dyck-path (cf. A014486).

Crossrefs

Intersection of A000040 and A095100. Subset of A080114 (see comments there). Complement of A095103 in A002145.
Cf. A095092.

Programs

  • Mathematica
    isMotzkin[n_, k_] := Module[{s = 0, r = True}, Do[s += JacobiSymbol[i, n]; If[s < 0, r = False; Break[]], {i, 1, k}]; r]; A095102[max_] := Select[ Range[3, max, 4], PrimeQ[#] && isMotzkin[#, Quotient[#, 2]]&]; A095102[1151] (* Jean-François Alcover, Feb 16 2018, after Peter Luschny *)
  • PARI
    isok(m) = {if(!isprime(m-(m<3)), return(0)); my(s=0); for(i=1, m-1, if((s+=kronecker(i, m))<0, return(0))); 1; } \\ Jinyuan Wang, Jul 20 2020
  • Sage
    def A095102_list(n) :
        def is_Motzkin(n, k):
            s = 0
            for i in (1..k):
                s += jacobi_symbol(i, n)
                if s < 0: return False
            return True
        P = filter(is_prime, range(3, n+1, 4))
        return filter(lambda m: is_Motzkin(m, m//2), P)
    A095102_list(1151) # Peter Luschny, Aug 09 2012
    

Formula

a(n) = 4*A095272(n) + 3.

A095070 One-bit dominant primes, i.e., primes whose binary expansion contains more 1's than 0's.

Original entry on oeis.org

3, 5, 7, 11, 13, 19, 23, 29, 31, 43, 47, 53, 59, 61, 71, 79, 83, 89, 101, 103, 107, 109, 113, 127, 151, 157, 167, 173, 179, 181, 191, 199, 211, 223, 227, 229, 233, 239, 241, 251, 271, 283, 307, 311, 313, 317, 331, 347, 349, 359, 367, 373, 379, 383
Offset: 1

Author

Antti Karttunen, Jun 01 2004

Keywords

Examples

			23 is in the sequence because 23 is a prime and 23_10 = 10111_2. '10111' has four 1's and one 0. - _Indranil Ghosh_, Jan 31 2017
		

Crossrefs

Intersection of A000040 and A072600.
Complement of A095075 in A000040.
Subsequence: A095073.
Cf. A095020.

Programs

  • Mathematica
    Select[Prime[Range[70]], Plus@@IntegerDigits[#, 2] > Length[IntegerDigits[#, 2]]/2 &] (* Alonso del Arte, Jan 11 2011 *)
    Select[Prime[Range[100]], Differences[DigitCount[#, 2]][[1]] < 0 &] (* Amiram Eldar, Jul 25 2023 *)
  • PARI
    B(x) = {nB = floor(log(x)/log(2)); b1 = 0; b0 = 0;
    for(i = 0, nB, if(bittest(x,i), b1++;, b0++;); );
    if(b1 > b0, return(1);, return(0););};
    forprime(x = 3, 383, if(B(x), print1(x, ", "); ); ); \\ Washington Bomfim, Jan 11 2011
    
  • PARI
    has(n)=hammingweight(n)>#binary(n)/2
    select(has, primes(500)) \\ Charles R Greathouse IV, May 02 2013
    
  • Python
    # Program to generate the b-file
    from sympy import isprime
    i=1
    j=1
    while j<=200:
        if isprime(i) and bin(i)[2:].count("1")>bin(i)[2:].count("0"):
            print(str(j)+" "+str(i))
            j+=1
        i+=1 # Indranil Ghosh, Jan 31 2017

A095100 Integers m of the form 4k+3 for which all sums Sum_{i=1..u} J(i/m) (with u ranging from 1 to (m-1)) are nonnegative, where J(i/m) is Jacobi symbol of i and m.

Original entry on oeis.org

3, 7, 11, 15, 23, 27, 31, 35, 39, 47, 55, 59, 63, 71, 75, 79, 83, 87, 95, 103, 111, 119, 131, 135, 143, 151, 159, 167, 171, 175, 183, 191, 199, 215, 231, 239, 243, 251, 255, 263, 271, 279, 287, 295, 299, 303, 311, 319, 327, 335, 343, 351, 359, 363
Offset: 1

Author

Antti Karttunen, Jun 01 2004

Keywords

Comments

Integers whose Jacobi-vector forms a valid Motzkin-path.

Crossrefs

Subset of A095102. Complement of A095101 in A004767.
Cf. A095090.

Programs

  • Mathematica
    isMotzkin[n_, k_] := Module[{s = 0, r = True}, Do[s += JacobiSymbol[i, n]; If[s < 0, r = False; Break[]], {i, 1, k}]; r]; A095100[n_] := Select[4*Range[0, n+1]+3, isMotzkin[#, Quotient[#, 2]] &]; A095100[90] (* Jean-François Alcover, Oct 08 2013, translated from Sage *)
  • PARI
    isok(m) = {if(m%4<3, return(0)); my(s=0); for(i=1, m-1, if((s+=kronecker(i, m))<0, return(0))); 1; } \\ Jinyuan Wang, Jul 20 2020
  • Sage
    def is_Motzkin(n, k):
        s = 0
        for i in range(1, k + 1) :
            s += jacobi_symbol(i, n)
            if s < 0: return False
        return True
    def A095100_list(n):
        return [m for m in range(3, n + 1, 4) if is_Motzkin(m, m // 2)]
    A095100_list(363) # Peter Luschny, Aug 08 2012
    

Formula

a(n) = 4*A095274(n) + 3.

A095008 Number of 4k+3 primes (A002145) in range ]2^n,2^(n+1)].

Original entry on oeis.org

1, 1, 1, 3, 3, 7, 13, 22, 37, 71, 128, 231, 440, 807, 1519, 2872, 5371, 10204, 19341, 36759, 70179, 134241, 256856, 492936, 947272, 1822615, 3513691, 6781495, 13103816, 25348667, 49092241, 95168205, 184661253, 358636497, 697094872, 1356052491, 2639893495, 5142817901
Offset: 1

Author

Antti Karttunen and Labos Elemer, Jun 01 2004

Keywords

Formula

a(n) = A036378(n) - A095007(n) = A095010(n) + A095012(n) = A095092(n) + A095093(n).

Extensions

a(34)-a(38) from Amiram Eldar, Jun 12 2024

A095075 Primes in whose binary expansion the number of 1-bits is less than or equal to number of 0-bits.

Original entry on oeis.org

2, 17, 37, 41, 67, 73, 97, 131, 137, 139, 149, 163, 193, 197, 257, 263, 269, 277, 281, 293, 337, 353, 389, 401, 449, 521, 523, 541, 547, 557, 563, 569, 577, 587, 593, 601, 613, 617, 641, 643, 647, 653, 659, 661, 673, 677, 709, 769, 773, 787
Offset: 1

Author

Antti Karttunen, Jun 01 2004

Keywords

Examples

			From _Indranil Ghosh_, Feb 03 2017: (Start)
17 is in the sequence because 17_10 = 10001_2. '10001' has two 1's and three 0's.
37 is in the sequence because 37_10 = 100101_2. '100101' has three 1's and 3 0's. (End)
		

Crossrefs

Complement of A095070 in A000040.
Cf. A095055.

Programs

  • Mathematica
    Select[Prime[Range[150]], Differences[DigitCount[#, 2]][[1]] >= 0 &] (* Amiram Eldar, Jul 25 2023 *)
    Select[Prime[Range[150]],DigitCount[#,2,1]<=DigitCount[#,2,0]&] (* Harvey P. Dale, Sep 27 2023 *)
  • PARI
    B(x) = {nB = floor(log(x)/log(2)); z1 = 0; z0 = 0;
    for(i = 0, nB, if(bittest(x,i), z1++;, z0++;); );
    if(z1 <= z0, return(1);, return(0););};
    forprime(x = 2, 787, if(B(x), print1(x, ", "); ); );
    \\ Washington Bomfim, Jan 11 2011
    
  • Python
    from sympy import isprime
    i=1
    j=1
    while j<=250:
        if isprime(i) and bin(i)[2:].count("1")<=bin(i)[2:].count("0"):
            print(str(j)+" "+str(i))
            j+=1
        i+=1 # Indranil Ghosh, Feb 03 2017

A095071 Zero-bit dominant primes, i.e., primes whose binary expansion contains more 0's than 1's.

Original entry on oeis.org

17, 67, 73, 97, 131, 137, 193, 257, 263, 269, 277, 281, 293, 337, 353, 389, 401, 449, 521, 523, 547, 577, 593, 641, 643, 673, 769, 773, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1091, 1093, 1097, 1109, 1123, 1129, 1153, 1163, 1171
Offset: 1

Author

Antti Karttunen, Jun 01 2004

Keywords

Examples

			73 is in the sequence because 73 is a prime and 73_10 = 1001001_2. '1001001' has four 0's and one 1. - _Indranil Ghosh_, Jan 31 2017
		

Crossrefs

Complement of A095074 in A000040. Subset: A095072. Cf. A095019.

Programs

  • Mathematica
    Reap[Do[p=Prime[k];id=IntegerDigits[p,2];n=Length@id;If[Count[id,0]>n/2,Sow[p]],{k,200}]][[2,1]]
    (* Zak Seidov *)
    Select[Prime[Range[200]],DigitCount[#,2,0]>DigitCount[#,2,1]&] (* Harvey P. Dale, Nov 28 2024 *)
  • PARI
    B(x) = { nB = floor(log(x)/log(2)); b1 = 0; b0 = 0;
    for(i = 0, nB, if(bittest(x,i), b1++;, b0++;); );
    if(b0 > b1, return(1);, return(0););};
    forprime(x = 2, 1171, if(B(x), print1(x, ", "); ); ); \\ Washington Bomfim, Jan 11 2011
    
  • PARI
    {forprime(p=2,1171,nB=floor(log(p)/log(2));
    sum(i=0,nB,bittest(p,i))<=nB/2&print1(p,","))} \\ Zak Seidov, Jan 11 2011
    
  • Python
    #Program to generate the b-file
    from sympy import isprime
    i=1
    j=1
    while j<=200:
        if isprime(i) and bin(i)[2:].count("0")>bin(i)[2:].count("1"):
            print(str(j)+" "+str(i))
            j+=1
        i+=1 # Indranil Ghosh, Jan 31 2017

A095072 Primes in whose binary expansion the number of 0-bits is one more than the number of 1-bits.

Original entry on oeis.org

17, 67, 73, 97, 263, 269, 277, 281, 293, 337, 353, 389, 401, 449, 1039, 1051, 1063, 1069, 1109, 1123, 1129, 1163, 1171, 1187, 1193, 1201, 1249, 1291, 1301, 1321, 1361, 1543, 1549, 1571, 1609, 1667, 1669, 1697, 1801, 4127, 4157, 4211, 4217
Offset: 1

Author

Antti Karttunen, Jun 01 2004

Keywords

Comments

A010051(a(n)) = 1 and A037861(a(n)) = 1. - Reinhard Zumkeller, Mar 31 2015

Examples

			97 is in the sequence because 97 is a prime and 97_10 = 1100001_2. The number of 0's in 1100001 is 4 and the number of 1's is 3. - _Indranil Ghosh_, Jan 31 2017
		

Crossrefs

Intersection of A000040 and A031444. Subset of A095071.
Cf. A095052.

Programs

  • Haskell
    a095072 n = a095072_list !! (n-1)
    a095072_list = filter ((== 1) . a010051' . fromIntegral) a031444_list
    -- Reinhard Zumkeller, Mar 31 2015
    
  • Mathematica
    Select[Prime[Range[500]], Differences[DigitCount[#, 2]] == {1} &]
  • PARI
    isA095072(n)=my(v=binary(n));#v==2*sum(i=1,#v,v[i])+1&&isprime(n)
    
  • PARI
    forprime(p=2, 4250, v=binary(p); s=0; for(k=1, #v, s+=if(v[k]==0,+1,-1)); if(s==1,print1(p,", ")))
    
  • Python
    #Program to generate the b-file
    from sympy import isprime
    i=1
    j=1
    while j<=200:
        if isprime(i) and bin(i)[2:].count("0")-bin(i)[2:].count("1")==1:
            print(str(j)+" "+str(i))
            j+=1
        i+=1 # Indranil Ghosh, Jan 31 2017

A095298 Sum of 1-bits between the most and least significant bits summed for all primes in range ]2^n,2^(n+1)].

Original entry on oeis.org

0, 1, 2, 8, 15, 30, 67, 154, 302, 611, 1280, 2546, 5207, 10447, 21123, 42783, 85726, 173102, 347243, 698544, 1401784, 2813930, 5644165, 11328192, 22712057, 45538473, 91288241, 182965151, 366691833, 734702678, 1471976078, 2948741819
Offset: 1

Author

Antti Karttunen, Jun 04 2004

Keywords

Comments

Ratio a(n)/A036378(n) (i.e. average number of 1-bits in range ]most significant bit,least significant bit[ of primes p which 2^n < p < 2^(n+1)) grows as: 0, 0.5, 1, 1.6, 2.142857, 2.307692, 2.913043, 3.581395, 4.026667, 4.459854, 5.019608, 5.487069, 5.97133, 6.480769, 6.971287, 7.493957, 7.975254, 8.489554, 8.987783, 9.492893, 9.98877, 10.491283, 10.987107, 11.49116, 11.990823, 12.490859, 12.990533, 13.491108, 13.991985, 14.491881, 14.992221, 15.492331, 15.992713.
Ratio of that average compared to (n-1)/2 (the expected value of that same sum computed for all odd numbers in the same range) converges as: 1, 1, 1, 1.066667, 1.071429, 0.923077, 0.971014, 1.023256, 1.006667, 0.991079, 1.003922, 0.997649, 0.995222, 0.997041, 0.995898, 0.999194, 0.996907, 0.998771, 0.998643, 0.999252, 0.998877, 0.99917, 0.998828, 0.999231, 0.999235, 0.999269, 0.999272, 0.999341, 0.999427, 0.99944, 0.999481, 0.999505, 0.999545.

Examples

			a(1)=0, as only prime in range ]2,4] is 3, 11 in binary which has no space between its most and least significant bits. a(2)=1, as in that range there are two primes 5 (101 in binary) and 7 (111 in binary) and summing their middle bits we get 1. a(3)=2, as there are again two primes, 11 (1011 in binary) and 13 (1101 in binary) and summing the bits in the middle we get total 2.
		

Crossrefs

A095297, A095334. Cf. also A095353 (similar sums and ratios computed in Fibonacci number system).

A095005 Number of odious primes (A027697) in range ]2^n,2^(n+1)].

Original entry on oeis.org

0, 1, 2, 2, 5, 8, 19, 20, 48, 75, 160, 242, 505, 835, 1761, 2799, 5890, 10250, 20921, 36872, 74316, 134816, 267749, 492286, 977207, 1823657, 3598657, 6779899, 13336543, 25358424, 49763462, 95140695, 186504600, 358630024, 702300885, 1356118149, 2654709953, 5142968571
Offset: 1

Author

Antti Karttunen and Labos Elemer, Jun 01 2004

Keywords

Crossrefs

Programs

  • Mathematica
    Table[Count[Prime@ Range[PrimePi[2^n] + 1, PrimePi[2^(n + 1) - 1]], k_ /; OddQ@ First@ DigitCount[k, 2]], {n, 24}] (* Michael De Vlieger, Feb 25 2017 *)
  • PARI
    a(n) = #select(x->((hammingweight(x)%2)==1),primes([2^n+1,2^(n+1)])); \\ Michel Marcus, Feb 26 2017

Formula

a(n) = A036378(n) - A095006(n).

Extensions

a(34)-a(38) from Amiram Eldar, Jun 20 2024
Showing 1-10 of 143 results. Next