OFFSET
1,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
EXAMPLE
For n = 4: a(4) = 3, because prime(4) = 7, 3*7 + 2 = 23 which is prime.
MAPLE
a:= proc(n) local p, q, r; p:= ithprime(n); q:= p;
while irem(q-2, p, 'r')<>0 do q:= nextprime(q) od; r
end:
seq(a(n), n=1..99); # Alois P. Heinz, Dec 04 2023
MATHEMATICA
nmax=90; a[1]=0; For[n=2, n<=nmax, n++, For[k=1, k>0, k++, If[PrimeQ[k*Prime[n]+2], a[n]=k; k=-1]]]; Array[a, nmax] (* Stefano Spezia, Dec 04 2023 *)
PROG
(PARI) a(n) = if (n==1, 0, my(k=1, p=prime(n)); while (!isprime(k*p+2), k++); k); \\ Michel Marcus, Dec 02 2023
(Python)
from itertools import count, dropwhile
from sympy import prime, isprime
def A367805(n):
if n==1:
return 0
else:
p = prime(n)
return next(dropwhile(lambda x:not isprime(x*p+2), count(1))) # Chai Wah Wu, Jan 04 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Frank Hollstein, Dec 01 2023
EXTENSIONS
More terms from Michel Marcus, Dec 02 2023
STATUS
approved