cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A062021 a(n) = Sum_{i=1..n} Sum_{j=1..i} (prime(i)^2 - prime(j)^2).

Original entry on oeis.org

0, 5, 42, 151, 548, 1185, 2542, 4403, 7608, 13621, 20834, 32535, 47980, 65609, 88278, 119947, 162368, 208869, 269194, 340007, 416580, 512305, 622286, 756003, 925432, 1114661, 1314498, 1537015, 1771628, 2031993, 2393158, 2786315
Offset: 1

Views

Author

Amarnath Murthy, Jun 02 2001

Keywords

Examples

			a(3) = (5^2 - 2^2) + (5^2 - 3^2) + (3^2 - 2^2) = 42.
		

Crossrefs

Programs

  • Magma
    [(&+[(&+[NthPrime(i)^2 - NthPrime(j)^2: j in [1..i]]): i in [1..n]]): n in [1..40]]; // G. C. Greubel, May 04 2022
    
  • Maple
    N:= 100: # for a(1)..a(N)
    P2:= [seq(ithprime(i)^2,i=1..N)]:
    DP2:= P2[2..-1]-P2[1..-2]:
    A[1]:= 0: A[2]:= 5:
    for n from 3 to N do A[n]:= 2*A[n-1]+(n-1)*DP2[n-1]-A[n-2] od:
    seq(A[i],i=1..N); # Robert Israel, Feb 02 2020
  • Mathematica
    RecurrenceTable[{a[1]==0,a[2]==5,a[n]==2a[n-1]-a[n-2]+(n-1)(Prime[n]^2 - Prime[n-1]^2)}, a, {n,40}] (* Harvey P. Dale, May 16 2019 *)
  • SageMath
    @CachedFunction
    def a(n):
        if (n<3): return 5*(n-1)
        else: return 2*a(n-1) - a(n-2) + (n-1)*(nth_prime(n)^2 - nth_prime(n-1)^2)
    [a(n) for n in (1..40)] # G. C. Greubel, May 04 2022

Formula

a(n) = 2*a(n-1) - a(n-2) + (n-1)*(prime(n)^2 - prime(n-1)^2) with a(1) = 0, a(2) = 5.

Extensions

More terms and formula from Larry Reeves (larryr(AT)acm.org), Jun 06 2001
Name edited by G. C. Greubel, May 04 2022