OFFSET
1,1
COMMENTS
For p>2, f(x) is applied an even number of times, twice at least.
EXAMPLE
a(2) = f(f(3)) = (3^2 + 1)^2 + 1 = 101.
a(3) = f(f(5)) = (5^2 + 1)^2 + 1 = 677.
MATHEMATICA
Take[Union@ Flatten[Table[Nest[#^2 + 1 &, Prime@ n, #], {n, 150}] & /@ Range@ 6] /. n_ /; CompositeQ@ n -> Nothing, 23] (* Michael De Vlieger, Jan 06 2016 *)
PROG
(Python)
from sympy import isprime
a=[]
TOP=1000000
for p in range(TOP):
if isprime(p):
q=p
while q<TOP:
q = q*q+1
if isprime(q):
a.append(q)
print(sorted(set(a)))
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Dec 25 2015
STATUS
approved