OFFSET
1,1
COMMENTS
a(n) = 2 if and only if n is in A029707. - Robert Israel, Jan 16 2019
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
a := proc (n) local k: for k while isprime(ithprime(n+1)*k-ithprime(n)) = false do end do: ithprime(n+1)*k-ithprime(n) end proc: seq(a(n), n = 1 .. 65); # Emeric Deutsch, Aug 10 2009
MATHEMATICA
a[n_] := Module[{p, q, r}, For[p = Prime[n]; q = Prime[n + 1]; k = 1, True, k++, If[PrimeQ[r = q k - p], Return[r]]]];
Array[a, 100] (* Jean-François Alcover, Aug 28 2020 *)
PROG
(Python)
from sympy import isprime, nextprime, prime
def a(n):
pn = prime(n); pn1 = nextprime(pn); k = 1
while not isprime(pn1*k - pn): k += 1
return pn1*k - pn
print([a(n) for n in range(1, 62)]) # Michael S. Branicky, Jul 02 2021
(PARI) a(n) = my(k=1); while (!isprime(p=prime(n+1)*k - prime(n)), k++); p; \\ Michel Marcus, Jul 02 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Aug 07 2009
EXTENSIONS
Extended by Emeric Deutsch, Aug 10 2009
STATUS
approved