%I #11 Nov 12 2023 05:32:45
%S 5,17,11,13,19,257,37,29,43,47,41,67,53,59,71,61,79,73,83,97,103,89,
%T 101,131,113,107,109,151,139,191,137,193,149,163,157,167,197,173,179,
%U 181,199,223,521,263,211,227,239,229,233,241,251,271,367,65537,269,277,283
%N Smallest prime greater than n-th prime having as many ones in binary representation.
%C a(n)>A000040(n) and A010051(a(n))=1 and A000120(a(n))=A000120(A000040(n));
%C A019434(n+1) = a(A019434(n));
%C If A000040(6543)=A019434(5)=65537 is the last Fermat prime, the sequence is finite with last term a(6542)=73471.
%H Reinhard Zumkeller, <a href="/A180024/b180024.txt">Table of n, a(n) for n = 2..6542</a>
%e n=10: prime(10) = 29->11101 with 4 ones,
%e a(10) = prime(14) = 43->101011;
%e n=100: prime(100) = 541->1000011101 with 5 ones,
%e a(100) = prime(102) = 557->1000101101;
%e n=1000: prime(1000) = 7919->1111011101111 with 11 ones,
%e a(1000) = prime(1001) = 7927->1111011110111;
%e n=6542: prime(6542) = 65521->1111111111110001 with 13 ones,
%e a(6542) = prime(7255) = 73471->10001111011111111;
%e n=6543: prime(6543) = 65537->10000000000000001 with 2 ones,
%e a(6543) = unknown.
%t sp1b[n_]:=Module[{o=DigitCount[n,2,1],p=NextPrime[n]},While[ DigitCount[ p,2,1]!=o,p = NextPrime[ p]];p]; sp1b/@Prime[Range[2,60]] (* _Harvey P. Dale_, May 02 2019 *)
%o (PARI) a(n) = my(p=prime(n), x=hammingweight(p), q=nextprime(p+1)); while (hammingweight(q) != x, q=nextprime(q+1)); q; \\ _Michel Marcus_, Nov 12 2023
%Y Cf. A014499, A004676.
%K nonn
%O 2,1
%A _Reinhard Zumkeller_, Aug 07 2010