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.

Showing 1-4 of 4 results.

A351830 Distance from the n-th square pyramidal number (sum of the first n positive squares) to the nearest square.

Original entry on oeis.org

0, 0, 1, 2, 5, 6, 9, 4, 8, 4, 15, 22, 25, 22, 9, 15, 25, 21, 7, 30, 46, 53, 49, 32, 0, 49, 40, 41, 30, 91, 46, 12, 9, 15, 4, 26, 77, 114, 25, 91, 61, 105, 15, 122, 129, 66, 22, 1, 1, 24, 76, 157, 170, 37, 131, 141, 91, 139, 165, 15, 174, 247, 150, 80, 39, 29
Offset: 0

Views

Author

Paolo Xausa, Feb 21 2022

Keywords

Comments

As noted by Conway and Sloane (1999), the only zero terms appear at n = 0, n = 1 and n = 24, and the n = 24 case allows for the Lorentzian construction of the Leech lattice through the A351831 vector.
The zero terms are equivalently the subject of the "pile of cannonballs" problem posed by Lucas and solved by Watson. - Peter Munn, Aug 03 2023

Examples

			a(4) = 5 because the sum of the first 4 positive squares is 1 + 4 + 9 + 16 = 30, the nearest square is 25 and 30 - 25 = 5. - _Paolo Xausa_, Jul 05 2022
		

References

  • W. Ljunggren, New solution of a problem proposed by E. Lucas, Norsk Mat. Tidsskr. 34 (1952), pp 65-72.
  • David Wells, The Penguin Dictionary of Curious and Interesting Numbers, Penguin Books, 1987, entry 24, p 101.

Crossrefs

Programs

  • Mathematica
    nterms=66;Array[Abs[(s=#(#+1)(2#+1)/6)-Round[Sqrt[s]]^2]&,nterms,0]
  • Python
    from math import isqrt
    def a(n):
        t = n*(n+1)*(2*n+1)//6
        r = isqrt(t)
        return min(t - r**2, (r+1)**2 - t)
    print([a(n) for n in range(66)]) # Michael S. Branicky, Feb 21 2022

Formula

From Paolo Xausa, Jul 05 2022: (Start)
a(n) = A053188(A000330(n)).
a(n) = abs(A000330(n) - A353295(n)). (End)

Extensions

Name edited by Peter Munn, Aug 04 2023

A353295 Square nearest to the sum of the first n positive squares.

Original entry on oeis.org

0, 1, 4, 16, 25, 49, 100, 144, 196, 289, 400, 484, 625, 841, 1024, 1225, 1521, 1764, 2116, 2500, 2916, 3364, 3844, 4356, 4900, 5476, 6241, 6889, 7744, 8464, 9409, 10404, 11449, 12544, 13689, 14884, 16129, 17689, 19044, 20449, 22201, 23716, 25600, 27556, 29241
Offset: 0

Views

Author

Paolo Xausa, Jun 04 2022

Keywords

Examples

			a(4) = 25 because the sum of the first 4 positive squares is 1 + 4 + 9 + 16 = 30, and the nearest square is 25.
		

Crossrefs

Programs

  • Mathematica
    nterms=100;Array[Round[Sqrt[#(#+1)(2#+1)/6]]^2&,nterms,0]
  • Python
    from math import isqrt
    def a(n):
        s = n*(n+1)*(2*n+1)//6
        r = isqrt(s)
        d1, d2 = s-r**2, (r+1)**2-s
        return r**2 if d1 <= d2 else (r+1)**2
    print([a(n) for n in range(45)]) # Michael S. Branicky, Jun 05 2022

Formula

a(n) = A053187(A000330(n)).

A354329 Triangular number nearest to the sum of the first n positive triangular numbers.

Original entry on oeis.org

0, 1, 3, 10, 21, 36, 55, 78, 120, 171, 210, 276, 351, 465, 561, 666, 820, 990, 1128, 1326, 1540, 1770, 2016, 2278, 2628, 2926, 3240, 3655, 4095, 4465, 4950, 5460, 5995, 6555, 7140, 7750, 8385, 9180, 9870, 10731, 11476, 12403, 13203, 14196, 15225, 16290, 17205
Offset: 0

Views

Author

Paolo Xausa, Jun 04 2022

Keywords

Examples

			a(4) = 21 because the sum of the first 4 positive triangular numbers is 1 + 3 + 6 + 10 = 20, and the nearest triangular number is 21.
		

Crossrefs

Programs

  • Mathematica
    nterms=100;Table[t=Floor[Sqrt[n(n+1)(n+2)/3]];(t^2+t)/2,{n,0,nterms-1}]
  • PARI
    a(n)=my(t=sqrtint(n*(n+1)*(n+2)/3));(t^2+t)/2;
    vector(100,n,a(n-1))
    
  • Python
    from math import isqrt
    def A354329(n): return (m:=isqrt(n*(n*(n + 3) + 2)//3))*(m+1)>>1 # Chai Wah Wu, Jul 15 2022

Formula

a(n) = (t^2+t)/2, where t = floor(sqrt(n*(n+1)*(n+2)/3)).

A366092 Distance from the sum of the first n primes to the nearest prime.

Original entry on oeis.org

2, 0, 0, 1, 0, 1, 0, 1, 2, 1, 2, 3, 0, 1, 0, 3, 2, 1, 2, 1, 2, 3, 4, 3, 4, 1, 2, 5, 2, 1, 4, 1, 4, 1, 2, 3, 4, 5, 2, 3, 2, 5, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 10, 1, 0, 11, 2, 1, 0, 3, 2, 3, 2, 7, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 2, 5, 4, 3, 10, 3
Offset: 0

Views

Author

Paolo Xausa, Sep 29 2023

Keywords

Comments

Positions of zeros are given by A013916.
Positions of records are given by A366093.

Examples

			a(3) = 1 because the sum of the first 3 primes is 2 + 3 + 5 = 10, the nearest prime is 11 and 11 - 10 = 1.
		

Crossrefs

Programs

  • Mathematica
    pDist[n_]:=If[PrimeQ[n],0,Min[NextPrime[n]-n,n-NextPrime[n,-1]]];
    A366092list[nmax_]:=Map[pDist,Prepend[Accumulate[Prime[Range[nmax]]],0]];
    A366092list[100]
  • Python
    from sympy import prime, nextprime, prevprime
    def A366092(n): return min((m:=sum(prime(i) for i in range(1,n+1)))-prevprime(m+1),nextprime(m)-m) if n else 2 # Chai Wah Wu, Oct 03 2023

Formula

a(n) = A051699(A007504(n)).
a(n) = abs(A007504(n) - A366094(n)).
Showing 1-4 of 4 results.