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”).

A377897
Numbers k such that k + PrimePi(k) is even.
2
4, 5, 8, 10, 11, 14, 16, 17, 20, 22, 23, 25, 27, 30, 31, 33, 35, 38, 40, 41, 44, 46, 47, 49, 51, 54, 56, 58, 59, 62, 64, 66, 67, 69, 72, 73, 75, 77, 80, 82, 83, 85, 87, 90, 92, 94, 96, 97, 99, 102, 103, 105, 108, 109, 111, 114, 116, 118, 120, 122, 124, 126, 127, 129, 132, 134, 136, 137, 140
OFFSET
1,1
MATHEMATICA
Select[Range[200], EvenQ[# + PrimePi[#]] &] (* Paolo Xausa, Nov 13 2024 *)
PROG
(Python)
from sympy import nextprime
def A377897_gen(): # generator of terms
p, q, a = 3, 5, 1
while True:
yield from range(p+a, q, 2)
p, q, a = q, nextprime(q), a^1
A377897_list = list(islice(A377897_gen(), 69)) # Chai Wah Wu, Nov 13 2024
(Python)
from sympy import primepi, prevprime
def A377897(n):
def f(x):
if x<=3: return n+x
p = prevprime(x+1)
i = int(primepi(p))
return n+x-(p>>1)-(x-p-((i^x)&1)>>1)
m, k = n, f(n)
while m != k: m, k = k, f(k)
return m # Chai Wah Wu, Nov 13 2024
CROSSREFS
Cf. A000720, A121053, A377994 (complement).
Sequence in context: A340762 A092022 A346302 * A190200 A162902 A026491
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Nov 13 2024
STATUS
approved