login
Slowest increasing sequence where a(n) + n^2 is a prime.
1

%I #17 Apr 16 2023 20:27:20

%S 1,3,4,7,12,17,18,19,20,27,28,29,30,31,32,37,42,43,48,49,50,57,58,65,

%T 66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,93,96,97,100,103,104,

%U 105,124,133,138,147,148,153,154,163,166,171,184,193,196,197,198,205

%N Slowest increasing sequence where a(n) + n^2 is a prime.

%H Michael S. Branicky, <a href="/A362222/b362222.txt">Table of n, a(n) for n = 1..10000</a>

%e a(2) = 3, since the smallest number greater than all the previous terms which gives a prime when added to 2^2 is 3.

%p R:= 1: t:= 1:

%p for n from 2 to 100 do

%p t:= nextprime(t+n^2)-n^2;

%p R:= R,t

%p od:

%p R; # _Robert Israel_, Apr 11 2023

%t a[n_] := a[n] = Module[{k = a[n - 1] + 1}, While[! PrimeQ[n^2 + k], k++]; k]; a[0] = 0; Array[a, 100] (* _Amiram Eldar_, Apr 12 2023 *)

%o (PARI) seq(n)={my(a=vector(n), p=0); for(n=1, #a, p++; while(!isprime(p+n^2), p++); a[n]=p); a} \\ _Andrew Howroyd_, Apr 11 2023

%o (Python)

%o from sympy import nextprime

%o from itertools import count, islice

%o def agen(): # generator of terms

%o an = 1

%o for n in count(2):

%o yield an

%o an = nextprime(an + n**2) - n**2

%o print(list(islice(agen(), 62))) # _Michael S. Branicky_, Apr 16 2023

%Y Cf. A053000, A107819.

%K nonn

%O 1,2

%A _Angad Singh_, Apr 11 2023