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.

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

This page as a plain text file.
%I A095018 #31 Jul 23 2025 00:12:33
%S A095018 1,0,2,4,17,28,189,531,1990,5747,23902,76658,291478,982793,3677580,
%T A095018 13214719,49161612,177190667,664806798,2443387945
%N A095018 a(n) is the number of primes p which have exactly n zeros and n ones when written in binary.
%C A095018 a(n) is the number of terms in A066196 which lie between 2^(2n-1) and 2^2n inclusively.
%H A095018 Antti Karttunen and John Moyer, <a href="/A095062/a095062.c.txt">C-program for computing the initial terms of this sequence</a>.
%H A095018 <a href="/index/Pri#primesubsetpop2">Index entries for sequences related to occurrences of various subsets of primes in range ]2^n,2^(n+1)]</a>
%e A095018 a(1) = 1 since only 2_10 = 10_2 satisfies the criterion;
%e A095018 a(2) = 0 since there is no prime between 4 and 16 which meets the criterion.
%e A095018 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.
%e A095018 a(4) = 4 since 139, 149, 163 and 197 meet the criterion; etc.
%t A095018 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 *)
%o A095018 (Python)
%o A095018 from itertools import combinations
%o A095018 from sympy import isprime
%o A095018 def A095018(n): return sum(1 for d in combinations((1<<i for i in range(2*n-1)),n-1) if isprime((1<<(n<<1)-1)+sum(d))) # _Chai Wah Wu_, Jul 18 2025
%Y A095018 Cf. A066196, A095005, A095006, A095052, A095053, A280872.
%K A095018 nonn,base
%O A095018 1,3
%A A095018 _Antti Karttunen_, Jun 01 2004
%E A095018 Edited by _N. J. A. Sloane_, Jan 16 2017
%E A095018 a(18)-a(20) from _Amiram Eldar_, Nov 21 2020