login
Smallest prime p that remains prime through exactly n iterations of the function f(x) = (x^2 + 7)/8.
0

%I #12 Mar 04 2018 23:47:05

%S 2,3,89,263,386777,149953319

%N Smallest prime p that remains prime through exactly n iterations of the function f(x) = (x^2 + 7)/8.

%C Since f(7) = (7^2 + 7)/8 = 7, p=7 remains prime through infinitely many iterations of the function.

%e f(2) = (2^2 + 7)/8 = 11/8 (not a prime), and 2 is the smallest prime, so a(0) = 2.

%e f(3) = (3^2 + 7)/8 = 16/8 = 2 (prime), but (2^2 + 7)/8 = 11/8 (not a prime), so p remains prime through exactly one iteration, and p=3 is the smallest prime for which this is the case, so a(1) = 3.

%e f(89) = (89^2 + 7)/8 = 991 (prime), and f(991) = (991^2 + 7)/8 = 122761 (prime), but f(122761) = (122761^2 + 7)/8 = 1883782891 = 211 * 8927881 (not a prime), so p remains prime through exactly two iterations, and p=89 is the smallest prime for which this is the case, so a(2) = 89.

%t Block[{lim = 10^2, s}, s = Array[Length@ NestWhileList[(#^2 + 7)/8 &, Prime@ #, PrimeQ, 1, lim, -1] /. lim -> 0 &, 10^6]; Array[Prime@ FirstPosition[s, #][[1]] &, Max@ s]] (* _Michael De Vlieger_, Feb 18 2018 *)

%o (PARI) isprimeq(q) = {if (denominator(q) != 1, return (0)); isprime(q);}

%o isok(p, n) = {for (k=1, n, q = (p^2 + 7)/8; if (! isprimeq(q), return (0)); p = q;); q = (p^2 + 7)/8; return (! isprimeq(q));}

%o a(n) = {forprime(p=2, , if (isok(p, n), return (p)););} \\ _Michel Marcus_, Feb 26 2018

%Y Cf. A118940 (Primes p such that (p^2 + 7)/8 is prime).

%K nonn,hard,more

%O 0,1

%A _Jon E. Schoenfield_, Feb 16 2018