login
A377758
a(n) is the least i such that 2n-prime(i) is also a prime, where prime(i) is the i-th prime.
3
1, 2, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 3, 4, 2, 2, 3, 4, 2, 3, 2, 2, 3, 2, 3, 4, 2, 3, 4, 2, 2, 3, 4, 2, 3, 2, 2, 3, 4, 2, 3, 2, 3, 4, 2, 3, 4, 8, 2, 3, 2, 2, 3, 2, 2, 3, 2, 3, 4, 6, 5, 6, 8, 2, 3, 2, 3, 4, 2, 2, 3, 4, 5, 5, 2, 2, 3, 4, 2, 3, 4, 2, 3, 2, 3
OFFSET
2,2
LINKS
FORMULA
a(n) = pi(A020481(n)).
MAPLE
f:= proc(n) local i, p;
p:= 1:
for i from 1 do
p:= nextprime(p);
if isprime(2*n-p) then return i fi
od
end proc:
map(f, [$2..100]); # Robert Israel, Nov 19 2024
MATHEMATICA
Table[Module[{i = 1}, While[i <= PrimePi[n] && ! PrimeQ[n - Prime[i]], i++]; If[i <= PrimePi[n], i, None]], {n, 4, 1000, 2}]
PROG
(PARI) a(n) = my(i=1); while (!isprime(2*n-prime(i)), i++); i; \\ Michel Marcus, Nov 06 2024
(Python)
from sympy import primerange, isprime
def A377758(n): return next(i for i, p in enumerate(primerange(2*n), 1) if isprime((n<<1)-p)) # Chai Wah Wu, Nov 19 2024
CROSSREFS
KEYWORD
nonn,new
AUTHOR
STATUS
approved