login
(n+1)^2 - (smallest prime > n^2).
4

%I #21 Jan 22 2019 15:07:06

%S 2,4,5,8,7,12,11,14,17,20,17,20,23,28,29,32,31,30,33,40,41,42,35,48,

%T 45,52,51,54,47,54,57,58,65,62,67,72,71,74,77,80,71,72,75,76,89,80,91,

%U 92,89,98,95,102,97,108,99,112,113,110,109,114,117,122,107,126,127,132,131

%N (n+1)^2 - (smallest prime > n^2).

%C Suggested by Conjecture 60 in Carlos Rivera's The Prime Puzzles & Problems Connection.

%C Legendre's conjecture that there is always a prime between n^2 and (n+1)^2 is equivalent to a(n) >= 0 for all n. As the conjecture is still opened, it is not proved that a(n) is nonn, although the keyword is automatically added. - _Jean-Christophe Hervé_, Oct 26 2013

%H Jean-Christophe Hervé, <a href="/A144831/b144831.txt">Table of n, a(n) for n = 1..10000</a>

%F Calculate n^2 and (n+1)^2, e.g. 4 - 9. Find the next prime following n^2 and subtract from (n+1)^2. Next prime is 5 so 9-5=4, the distance from next prime to (n+1)^2.

%F a(n) = (n+1)^2 - A007491(n).

%e a(2)=4 because n=2, 2^2=4 and (2+1)^2=9. The gap in which primes are to be found is 4 - 9. Next prime=5 and 9-5=4. For a(3)=5, 3^2=9 and (3+1)^2=16. Next prime=11 and 16-11=5.

%t Table[n^2-NextPrime[(n-1)^2],{n,2,70}] (* _Harvey P. Dale_, Jan 22 2019 *)

%o (PARI) a(n) = (n+1)^2 - nextprime(n^2); \\ _Michel Marcus_, Jun 08 2014

%Y Cf. A007491, A053000, A144832, A144256, A014085.

%K nonn,easy

%O 1,1

%A _Enoch Haga_, Sep 21 2008

%E Definition rewritten by _N. J. A. Sloane_, Sep 28 2008

%E Definition rewritten by _Jean-Christophe Hervé_, Oct 26 2013