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.

Previous Showing 11-20 of 31 results. Next

A372517 Least k such that the k-th prime number has exactly n ones in its binary expansion.

Original entry on oeis.org

1, 2, 4, 9, 11, 64, 31, 76, 167, 309, 502, 801, 1028, 7281, 6363, 12079, 12251, 43237, 43390, 146605, 291640, 1046198, 951351, 2063216, 3957778, 11134645, 14198321, 28186247, 54387475, 249939829, 105097565, 393248783, 751545789, 1391572698, 2182112798, 8242984130
Offset: 1

Views

Author

Gus Wiseman, May 12 2024

Keywords

Comments

In other words, the a(n)-th prime is the least with binary weight n. The sorted version is A372686.

Examples

			The primes A000040(a(n)) together with their binary expansions and binary indices begin:
        2:                     10 ~ {2}
        3:                     11 ~ {1,2}
        7:                    111 ~ {1,2,3}
       23:                  10111 ~ {1,2,3,5}
       31:                  11111 ~ {1,2,3,4,5}
      311:              100110111 ~ {1,2,3,5,6,9}
      127:                1111111 ~ {1,2,3,4,5,6,7}
      383:              101111111 ~ {1,2,3,4,5,6,7,9}
      991:             1111011111 ~ {1,2,3,4,5,7,8,9,10}
     2039:            11111110111 ~ {1,2,3,5,6,7,8,9,10,11}
     3583:           110111111111 ~ {1,2,3,4,5,6,7,8,9,11,12}
     6143:          1011111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,13}
     8191:          1111111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,12,13}
    73727:      10001111111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,12,13,17}
    63487:       1111011111111111 ~ {1,2,3,4,5,6,7,8,9,10,11,13,14,15,16}
		

Crossrefs

Positions firsts of first appearances in A014499.
Taking primes gives A061712.
Counting zeros (weight) gives A372474, firsts of A035103.
For binary length we have A372684 (take primes A104080), firsts of A035100.
The sorted version is A372686, taking primes A372685.
A000120 counts ones in binary expansion (binary weight), zeros A080791.
A029837 gives greatest binary index, least A001511.
A030190 gives binary expansion, reversed A030308.
A048793 lists binary indices, reverse A272020, sum A029931.
A372471 lists binary indices of primes.

Programs

  • Mathematica
    spsm[y_]:=Max@@NestWhile[Most,y,Union[#]!=Range[Max@@#]&];
    j=DigitCount[#,2,1]&/@Select[Range[1000],PrimeQ];
    Table[Position[j,k][[1,1]],{k,spsm[j]}]
  • PARI
    a(n) = my(k=1, p=2); while(hammingweight(p) !=n, p = nextprime(p+1); k++); k; \\ Michel Marcus, May 13 2024
    
  • Python
    from itertools import count
    from sympy import isprime, primepi
    from sympy.utilities.iterables import multiset_permutations
    def A372517(n):
        for l in count(n-1):
            m = 1<Chai Wah Wu, May 13 2024

Formula

A000040(a(n)) = A061712(n).

Extensions

a(32)-a(36) from Pontus von Brömssen, May 13 2024

A372516 Number of ones minus number of zeros in the binary expansion of the n-th prime number.

Original entry on oeis.org

0, 2, 1, 3, 2, 2, -1, 1, 3, 3, 5, 0, 0, 2, 4, 2, 4, 4, -1, 1, -1, 3, 1, 1, -1, 1, 3, 3, 3, 1, 7, -2, -2, 0, 0, 2, 2, 0, 2, 2, 2, 2, 6, -2, 0, 2, 2, 6, 2, 2, 2, 6, 2, 6, -5, -1, -1, 1, -1, -1, 1, -1, 1, 3, 1, 3, 1, -1, 3, 3, -1, 3, 5, 3, 5, 7, -1, 1, -1, 1, 1
Offset: 1

Views

Author

Gus Wiseman, May 13 2024

Keywords

Comments

Absolute value is A177718.

Examples

			The binary expansion of 83 is (1,0,1,0,0,1,1), and 83 is the 23rd prime, so a(23) = 4 - 3 = 1.
		

Crossrefs

The sum instead of difference is A035100, firsts A372684 (primes A104080).
The negative version is A037861(A000040(n)).
Restriction of A145037 to the primes.
The unsigned version is A177718.
- Positions of zeros are A177796, indices of the primes A066196.
- Positions of positive terms are indices of the primes A095070.
- Positions of negative terms are indices of the primes A095071.
- Positions of negative ones are A372539, indices of the primes A095072.
- Positions of ones are A372538, indices of the primes A095073.
- Positions of nonnegative terms are indices of the primes A095074.
- Positions of nonpositive terms are indices of the primes A095075.
A000120 counts ones in binary expansion (binary weight), zeros A080791.
A030190 gives binary expansion, reversed A030308.
A035103 counts zeros in binary expansion of primes, firsts A372474.
A048793 lists binary indices, reverse A272020, sum A029931.
A070939 gives length of binary expansion.
A101211 lists run-lengths in binary expansion, row-lengths A069010.
A372471 lists the binary indices of each prime.

Programs

  • Mathematica
    Table[DigitCount[Prime[n],2,1]-DigitCount[Prime[n],2,0],{n,100}]
    DigitCount[#,2,1]-DigitCount[#,2,0]&/@Prime[Range[100]] (* Harvey P. Dale, May 09 2025 *)

Formula

a(n) = A000120(A000040(n)) - A080791(A000040(n)).
a(n) = A014499(n) - A035103(n).
a(n) = A145037(A000040(n))

A177718 a(n) = |(number of 1's in binary representation of prime(n)) - (number of 0's in binary representation of prime(n))|.

Original entry on oeis.org

0, 2, 1, 3, 2, 2, 1, 1, 3, 3, 5, 0, 0, 2, 4, 2, 4, 4, 1, 1, 1, 3, 1, 1, 1, 1, 3, 3, 3, 1, 7, 2, 2, 0, 0, 2, 2, 0, 2, 2, 2, 2, 6, 2, 0, 2, 2, 6, 2, 2, 2, 6, 2, 6, 5, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 3, 3, 1, 3, 5, 3, 5, 7, 1, 1, 1, 1, 1, 1, 5, 1, 5, 5, 1, 1, 3, 5, 3, 7, 5, 5, 5, 7, 7, 4, 2, 0, 2, 0, 0, 0, 2
Offset: 1

Views

Author

Juri-Stepan Gerasimov, May 12 2010, May 18 2010

Keywords

Examples

			a(1)=0 because 2 = 10_2 and abs(1-1) = 0;
a(2)=2 because 3 = 11_2 and abs(0-2) = 2;
a(3)=1 because 5 = 101_2 and abs(1-2) = 1.
		

Crossrefs

Programs

  • Maple
    A023416 := proc(n) a := 0 ; for d in convert(n,base,2) do if d = 0 then a := a+1 ; end if; end do; a ; end proc:
    A000120 := proc(n) a := 0 ; for d in convert(n,base,2) do if d = 1 then a := a+1 ; end if; end do; a ; end proc:
    A037861 := proc(n) A023416(n)-A000120(n) ; end proc:
    A177718 := proc(n) abs(A037861(ithprime(n))) ; end proc: seq(A177718(n),n=1..120) ; # R. J. Mathar, May 15 2010
    # second Maple program:
    a:= n-> abs(add(2*i-1, i=Bits[Split](ithprime(n)))):
    seq(a(n), n=1..105);  # Alois P. Heinz, Jan 18 2022
  • Mathematica
    nzmnu[n_]:=Module[{z=DigitCount[n,2,0]},Abs[2z-IntegerLength[n,2]]]; nzmnu/@ Prime[Range[110]] (* Harvey P. Dale, Feb 15 2015 *)
  • Python
    from sympy import isprime
    print([abs(bin(n)[2:].count("1") - bin(n)[2:].count("0")) for n in range (0,1000) if isprime(n)]) # Karl-Heinz Hofmann, Jan 18 2022

Formula

a(n) = abs(A014499(n) - A035103(n)).
a(n) = abs(A037861(prime(n))). - R. J. Mathar, May 15 2010

Extensions

Corrected at three or more places by R. J. Mathar, May 15 2010

A177796 Numbers n such that number of 1's in binary representation of n-th prime = number of 0's in binary representation of n-th prime.

Original entry on oeis.org

1, 12, 13, 34, 35, 38, 45, 100, 102, 103, 104, 107, 110, 112, 113, 118, 119, 120, 121, 123, 127, 138, 140, 158, 323, 328, 331, 335, 339, 345, 348, 350, 353, 355, 356, 359, 365, 366, 380, 385, 393, 394, 396, 398, 412, 414, 415, 419, 425, 456, 472, 484
Offset: 1

Views

Author

Juri-Stepan Gerasimov, May 14 2010

Keywords

Crossrefs

Programs

  • Mathematica
    n1Q[n_]:=Module[{idn2=IntegerDigits[Prime[n],2]},Count[idn2,1] == Length[idn2]/2]; Select[Range[500],n1Q] (* Harvey P. Dale, Jun 26 2013 *)
  • PARI
    is(n)=n=prime(n);hammingweight(n)==hammingweight(bitneg(n, #binary(n))) \\ Charles R Greathouse IV, Mar 29 2013

Formula

A014499(a(n))=A035103(a(n)).

Extensions

Entries checked by D. S. McNeil, Nov 26 2010

A072577 Numbers k such that k and the k-th prime have the same number of 0's in their binary representation.

Original entry on oeis.org

5, 6, 20, 22, 24, 28, 31, 32, 34, 37, 41, 42, 49, 50, 67, 68, 81, 82, 84, 88, 89, 93, 94, 138, 139, 140, 141, 142, 143, 147, 151, 157, 165, 192, 194, 198, 200, 202, 206, 207, 232, 236, 241, 262, 265, 270, 271, 284, 285, 295, 301, 328, 329, 332, 333, 337
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 23 2002

Keywords

Examples

			In binary representation 20 and A000040(20) = 71 have three 0's: 13 = '10100' and 71 = '1000111', therefore 20 is a term.
		

Crossrefs

Programs

  • Mathematica
    q[k_] := DigitCount[k, 2, 0] == DigitCount[Prime[k], 2, 0]; Select[Range[350], q] (* Amiram Eldar, Jul 28 2025 *)

Formula

A023416(a(n)) = A023416(A072580(n)) = A035103(n).
a(n) = A049084(A072580(n)).

A072579 In binary representation: k has the same number of 1's as the k-th prime has 0's.

Original entry on oeis.org

1, 7, 13, 26, 37, 41, 42, 45, 49, 50, 58, 59, 62, 69, 70, 74, 78, 79, 87, 103, 105, 107, 110, 114, 118, 121, 134, 139, 141, 142, 145, 147, 158, 161, 162, 164, 165, 168, 175, 185, 189, 198, 202, 203, 213, 214, 223, 227, 232, 234, 243, 267, 275, 282, 289, 292
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 23 2002

Keywords

Examples

			In binary representation 70 = '1000110' has three 1's and A000040(70) = 349 = '101011101' has three 1's: therefore 70 is a term.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[300],DigitCount[#,2,1]==DigitCount[Prime[#],2,0]&] (* Harvey P. Dale, May 02 2012 *)

Formula

A023416(A072582(n)) = A000120(a(n)) = A035103(n).
a(n) = A049084(A072582(n)).

A072580 a(n) = A000040(A072577(n)).

Original entry on oeis.org

11, 13, 71, 79, 89, 107, 127, 131, 139, 157, 179, 181, 227, 229, 331, 337, 419, 421, 433, 457, 461, 487, 491, 787, 797, 809, 811, 821, 823, 853, 877, 919, 977, 1163, 1181, 1213, 1223, 1231, 1277, 1279, 1459, 1487, 1523, 1667, 1697, 1733, 1741, 1861, 1867
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 23 2002

Keywords

Examples

			In binary representation 20 and A000040(20) = 71 have three 0's: 13 = '10100' and 71 = '1000111', therefore 71 is a term.
		

Crossrefs

Programs

  • Mathematica
    With[{m = 300}, Select[Transpose[{Range[m], Prime[Range[m]]}], Equal @@ DigitCount[#, 2, 0] &]][[;; , 2]] (* Amiram Eldar, Jul 27 2025 *)

Formula

A023416(a(n)) = A023416(A072577(n)) = A035103(n).

A072582 a(n) = A000040(A072579(n)).

Original entry on oeis.org

2, 17, 41, 101, 157, 179, 181, 197, 227, 229, 271, 277, 293, 347, 349, 373, 397, 401, 449, 563, 571, 587, 601, 619, 647, 661, 757, 797, 811, 821, 829, 853, 929, 947, 953, 971, 977, 997, 1039, 1103, 1129, 1213, 1231, 1237, 1303, 1307, 1409, 1433, 1459
Offset: 1

Views

Author

Reinhard Zumkeller, Jun 23 2002

Keywords

Examples

			In binary representation 70 = '1000110' has three 1's and A000040(70) = 349 = '101011101' has three 1's: therefore 349 is a term.
		

Crossrefs

Programs

  • Mathematica
    With[{m = 300}, Select[Transpose[{Range[m], Prime[Range[m]]}], DigitCount[First[#], 2, 1] == DigitCount[Last[#], 2, 0] &]][[;; , 2]] (* Amiram Eldar, Jul 28 2025 *)

Formula

A023416(a(n)) = A000120(A072579(n)) = A035103(n).

A372686 Sorted list of positions of first appearances in A014499 (number of ones in binary expansion of each prime).

Original entry on oeis.org

1, 2, 4, 9, 11, 31, 64, 76, 167, 309, 502, 801, 1028, 6363, 7281, 12079, 12251, 43237, 43390, 146605, 291640, 951351, 1046198, 2063216, 3957778, 11134645, 14198321, 28186247, 54387475, 105097565, 249939829, 393248783, 751545789, 1391572698, 2182112798, 8242984130
Offset: 1

Views

Author

Gus Wiseman, May 14 2024

Keywords

Comments

The unsorted version is A372517.

Examples

			The sequence contains 9 because the first 9 terms of A014499 are 1, 2, 2, 3, 3, 3, 2, 3, 4, and the last of these is the first position of 4.
		

Crossrefs

Positions of first appearances in A014499.
The unsorted version is A372517.
For binary length we have A372684, primes A104080, firsts of A035100.
Taking primes gives A372685, unsorted version A061712.
A000120 counts ones in binary expansion (binary weight), zeros A080791.
A029837 gives greatest binary index, least A001511.
A030190 gives binary expansion, reversed A030308.
A035103 counts zeros in binary expansion of each prime, firsts A372474.
A048793 lists binary indices, reverse A272020, sum A029931.
A070939 gives length of binary expansion (number of bits).
A372471 lists binary indices of primes.

Programs

  • Mathematica
    First/@GatherBy[Range[1000],DigitCount[Prime[#],2,1]&]

Formula

prime(a(n)) = A372685(n).

Extensions

a(26)-a(36) from Pontus von Brömssen, May 15 2024

A178064 Number of 0's in binary representation of n-th semiprime.

Original entry on oeis.org

2, 1, 2, 2, 1, 0, 2, 2, 2, 2, 4, 4, 3, 3, 2, 2, 3, 2, 1, 2, 2, 1, 5, 4, 4, 3, 4, 3, 3, 2, 2, 2, 2, 1, 3, 1, 2, 2, 1, 2, 2, 1, 6, 5, 5, 4, 4, 3, 5, 5, 3, 3, 2, 5, 4, 4, 4, 4, 2, 3, 2, 5, 4, 4, 3, 3, 3, 4, 3, 3, 2, 3, 3, 2, 2, 4, 2, 2, 1, 2, 1, 1, 6, 6, 6, 5, 6, 5, 3, 6, 5, 4, 5, 4, 4, 4, 3, 5, 4, 4, 2, 6, 5, 5, 4
Offset: 1

Views

Author

Juri-Stepan Gerasimov, May 18 2010

Keywords

Examples

			a(1)=2 because 1st semiprime = 4 = 100_2.
a(2)=1 because 2nd semiprime = 6 = 110_2.
		

Crossrefs

Programs

  • Maple
    A023416 := proc(n) a := 0 ; for d in convert(n,base,2) do if d = 0 then a := a+1 ; end if; end do; a ; end proc:
    A178064 := proc(n) A023416(A001358(n)) ; end proc:
    seq(A178064(n),n=1..120) ; # R. J. Mathar, May 23 2010
  • Mathematica
    DigitCount[#, 2, 0] & /@ Select[Range@ 328, PrimeOmega@ # == 2 &] (* Michael De Vlieger, Feb 02 2015 *)

Formula

a(n) = A023416(A001358(n)). - R. J. Mathar, May 23 2010

Extensions

a(56) corrected by R. J. Mathar, May 23 2010
Previous Showing 11-20 of 31 results. Next