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-2 of 2 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

A366094 Least prime nearest to the sum of the first n primes.

Original entry on oeis.org

2, 2, 5, 11, 17, 29, 41, 59, 79, 101, 127, 157, 197, 239, 281, 331, 379, 439, 499, 569, 641, 709, 787, 877, 967, 1061, 1163, 1259, 1373, 1481, 1597, 1721, 1847, 1987, 2129, 2273, 2423, 2579, 2749, 2917, 3089, 3271, 3449, 3637, 3833, 4027, 4229, 4441, 4663, 4889
Offset: 0

Views

Author

Paolo Xausa, Sep 29 2023

Keywords

Examples

			a(3) = 11 because the sum of the first 3 primes is 2 + 3 + 5 = 10 and the nearest prime is 11.
a(10) = 127 because the sum of the first 10 primes is 129, which is equidistant from the nearest primes (127 and 131), and 127 is the smaller one.
		

Crossrefs

Programs

  • Mathematica
    pNearest[n_]:=If[PrimeQ[n],n,With[{np=NextPrime[n],pp=NextPrime[n,-1]},If[np-nA366094list[nmax_]:=Prepend[Map[pNearest,Accumulate[Prime[Range[nmax]]]],2];
    A366094list[100]
  • Python
    from sympy import prime, nextprime, prevprime
    def A366094(n): return (p if ((m:=sum(prime(i) for i in range(1,n+1)))<<1)-(p:=prevprime(m+1))<=(k:=nextprime(m)) else k) if n else 2 # Chai Wah Wu, Oct 03 2023
Showing 1-2 of 2 results.