OFFSET
0,1
COMMENTS
For n > 2, a(n) must be of the form 36k + 11. This is seen by induction since 36k + 11 + m^2 is even if m is odd and since 36k + 11 + (6m + 2)^2 and 36k + 11 + (6m + 4)^2 are both divisible by 3. - Gerald McGarvey, Jun 03 2007
LINKS
Zak Seidov, Table of n, a(n) for n = 0..1000
EXAMPLE
After 3, we skip over 5 because 5 - 3 = 2, which is not a square, but 7 - 3 = 4 = 2^2, so 7 follows 3 in the sequence.
11 is the next prime after 7 and it differs from 7 by 4, so 11 follows 7 in the sequence.
47 differs from 11 by 36 = 6^2 and no prime between 11 and 47 differs from 11 by a square, so 47 is the next term after 11.
MATHEMATICA
p = 11; s2 = Join[{2, 3, 7, 11}, Table[x = 6; While[!PrimeQ[a = p + x^2], x = x + 6]; p = a, {99}]] (* Murthy *)
nxt[n_] := Module[{np = NextPrime[n]}, While[!IntegerQ[Sqrt[np - n]], np = NextPrime[np]]; np]; NestList[nxt, 2, 50] (* Harvey P. Dale, Mar 13 2013 *)
PROG
(PARI) print1(a=2, ", "); for(n=1, 43, k=1; while(!isprime(b=a+k^2), k++); print1(a=b, ", "))
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Aug 05 2002
EXTENSIONS
Edited and extended by Klaus Brockhaus, Aug 07 2002
STATUS
approved