login
Numbers k such that k + PrimePi(k) is odd.
2

%I #10 Nov 13 2024 18:29:22

%S 1,2,3,6,7,9,12,13,15,18,19,21,24,26,28,29,32,34,36,37,39,42,43,45,48,

%T 50,52,53,55,57,60,61,63,65,68,70,71,74,76,78,79,81,84,86,88,89,91,93,

%U 95,98,100,101,104,106,107,110,112,113,115,117,119,121,123,125

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

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

%t Select[Range[200], OddQ[# + PrimePi[#]] &]

%o (Python)

%o from sympy import prevprime, primepi

%o def A377994(n):

%o def f(x):

%o if x<=3: return n

%o p = prevprime(x+1)

%o i = int(primepi(p))

%o return n+(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

%o (Python)

%o from sympy import nextprime

%o def A377994_gen(): # generator of terms

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

%o yield from (1,2)

%o while True:

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

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

%o A377994_list = list(islice(A377994_gen(),40)) # _Chai Wah Wu_, Nov 13 2024

%Y Complement of A377897.

%Y Cf. A000720.

%K nonn,easy

%O 1,2

%A _Paolo Xausa_, Nov 13 2024