OFFSET
1,2
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:
vmax:= 0: recvals:= NULL:
for n from 1 to 10^7 do
v:= f(n);
if v > vmax then
vmax:= v; recvals:= recvals, v;
fi
od:
recvals;
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;
vmax = 0;
Reap[For[n = 1, n <= 10^6, n++, v = f[n]; If[v > vmax, vmax = v; Print["n = ", n, " v = ", v]; Sow[v]]]][[2, 1]] (* Jean-François Alcover, Oct 16 2020, after Maple *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Feb 02 2018
EXTENSIONS
a(34)-a(51) from Chai Wah Wu, Sep 10 2019
STATUS
approved