A299691 Smallest prime p that remains prime through exactly n iterations of the function f(x) = (x^2 + 7)/8.
2, 3, 89, 263, 386777, 149953319
Offset: 0
Examples
f(2) = (2^2 + 7)/8 = 11/8 (not a prime), and 2 is the smallest prime, so a(0) = 2. 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. 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.
Crossrefs
Cf. A118940 (Primes p such that (p^2 + 7)/8 is prime).
Programs
-
Mathematica
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 *)
-
PARI
isprimeq(q) = {if (denominator(q) != 1, return (0)); isprime(q);} 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));} a(n) = {forprime(p=2, , if (isok(p, n), return (p)););} \\ Michel Marcus, Feb 26 2018
Comments