OFFSET
1,2
REFERENCES
R. K. Guy, Unsolved Problems in Number Theory, Springer-Verlag, New York, Heidelberg, 1994, problem A8.
LINKS
T. D. Noe, Table of n, a(n) for n = 1..10000
Paul Erdös, Some problems on the distribution of prime numbers, C.I.M.E., Teoria dei numeri (1955).
D. R. Heath-Brown, Gaps between primes and the pair correlation of zeros of the zeta function, Acta Arithmetica, vol. XLI (1982), 85.
M. Wolf, Some conjectures on the gaps between consecutive primes, preprint IFTUWr 894//95, submitted to Asterisque.
FORMULA
MAPLE
with(numtheory): a := proc(n) option remember: if (n=1) then RETURN(1) else RETURN(a(n-1)+(ithprime(n+1)-ithprime(n))^2) fi: end:
MATHEMATICA
Rest[FoldList[Plus, 0, (#[[2]] - #[[1]])^2 & /@ Partition[Prime[Range[100]], 2, 1]]]
nn=60; With[{dsp=Differences[Prime[Range[nn+1]]]^2}, Table[Total[Take[ dsp, n]], {n, nn}]] (* Harvey P. Dale, Nov 30 2011 *)
Accumulate[Differences[Prime[Range[60]]]^2] (* Harvey P. Dale, May 08 2015 *)
PROG
(PARI) a(n) = sum(k=1, n, (prime(k+1) - prime(k))^2); \\ Michel Marcus, May 26 2018
(Python)
from sympy import nextprime
from itertools import islice, accumulate
def gen():
p, q = 2, 3
while True:
r = (q - p) ** 2
yield r
p, q = q, nextprime(q)
print(list(accumulate(islice(gen(), 51)))) # Adrienne Leonardo, Dec 18 2024
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
Antonio G. Astudillo (afg_astudillo(AT)hotmail.com), Sep 05 2002
STATUS
approved