login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Numbers k such that k + PrimePi(k) is even.
2

%I #20 Nov 14 2024 05:31:41

%S 4,5,8,10,11,14,16,17,20,22,23,25,27,30,31,33,35,38,40,41,44,46,47,49,

%T 51,54,56,58,59,62,64,66,67,69,72,73,75,77,80,82,83,85,87,90,92,94,96,

%U 97,99,102,103,105,108,109,111,114,116,118,120,122,124,126,127,129,132,134,136,137,140

%N Numbers k such that k + PrimePi(k) is even.

%H Paolo Xausa, <a href="/A377897/b377897.txt">Table of n, a(n) for n = 1..10000</a>

%t Select[Range[200], EvenQ[# + PrimePi[#]] &] (* _Paolo Xausa_, Nov 13 2024 *)

%o (Python)

%o from sympy import nextprime

%o def A377897_gen(): # generator of terms

%o p,q,a = 3,5,1

%o while True:

%o yield from range(p+a,q,2)

%o p, q, a = q, nextprime(q), a^1

%o A377897_list = list(islice(A377897_gen(),69)) # _Chai Wah Wu_, Nov 13 2024

%o (Python)

%o from sympy import primepi, prevprime

%o def A377897(n):

%o def f(x):

%o if x<=3: return n+x

%o p = prevprime(x+1)

%o i = int(primepi(p))

%o return n+x-(p>>1)-(x-p-((i^x)&1)>>1)

%o m, k = n, f(n)

%o while m != k: m, k = k, f(k)

%o return m # _Chai Wah Wu_, Nov 13 2024

%Y Cf. A000720, A121053, A377994 (complement).

%K nonn

%O 1,1

%A _N. J. A. Sloane_, Nov 13 2024