OFFSET
1,3
COMMENTS
For n > 1, a(n) == n+1 (mod 2). a(n) = 1 for n in A006093. - Robert Israel, Feb 02 2018
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
8+1 and 8+1^2 (9) isn't prime. 8+2 and 8+2^2 (10 and 12) aren't both prime. But 8+3 and 8+3^2 (11 and 17) are both prime. Thus a(8) = 3.
MAPLE
f:= proc(n) local k;
for k from (n mod 2)+1 by 2 do
if isprime(n+k) and isprime(n+k^2) then return k fi
od
end proc:
f(1):= 1:
map(f, [$1..100]); # Robert Israel, Feb 02 2018
MATHEMATICA
f[n_] := Module[{k}, For[k = Mod[n, 2] + 1, True, k += 2, If[PrimeQ[n + k] && PrimeQ[n + k^2], Return[k]]]]; f[1] = 1; f /@ Range[100] (* Jean-François Alcover, Feb 03 2018, after Robert Israel *)
PROG
(PARI) a(n)=for(k=1, 10^6, if(ispseudoprime(n+k)&&ispseudoprime(n+k^2), return(k)))
n=1; while(n<100, print1(a(n), ", "); n+=1)
(Python)
from sympy import isprime, nextprime
def A243145(n):
m = n
while True:
m = nextprime(m)
k = m-n
if isprime(n+k**2):
return k # Chai Wah Wu, Sep 03 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Derek Orr, May 30 2014
STATUS
approved