OFFSET
1,1
COMMENTS
Suggested by Conjecture 60 in Carlos Rivera's The Prime Puzzles & Problems Connection.
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
LINKS
Jean-Christophe Hervé, Table of n, a(n) for n = 1..10000
FORMULA
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.
a(n) = (n+1)^2 - A007491(n).
EXAMPLE
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.
MATHEMATICA
Table[n^2-NextPrime[(n-1)^2], {n, 2, 70}] (* Harvey P. Dale, Jan 22 2019 *)
PROG
(PARI) a(n) = (n+1)^2 - nextprime(n^2); \\ Michel Marcus, Jun 08 2014
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Enoch Haga, Sep 21 2008
EXTENSIONS
Definition rewritten by N. J. A. Sloane, Sep 28 2008
Definition rewritten by Jean-Christophe Hervé, Oct 26 2013
STATUS
approved