A372517 Least k such that the k-th prime number has exactly n ones in its binary expansion.
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
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
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
Extensions
a(32)-a(36) from Pontus von Brömssen, May 13 2024
Comments