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.

A034705 Numbers that are sums of consecutive squares.

Original entry on oeis.org

0, 1, 4, 5, 9, 13, 14, 16, 25, 29, 30, 36, 41, 49, 50, 54, 55, 61, 64, 77, 81, 85, 86, 90, 91, 100, 110, 113, 121, 126, 135, 139, 140, 144, 145, 149, 169, 174, 181, 190, 194, 196, 199, 203, 204, 221, 225, 230, 245, 255, 256, 265, 271, 280, 284, 285, 289, 294, 302
Offset: 1

Views

Author

Keywords

Comments

Also, differences of any pair of square pyramidal numbers (A000330). These could be called "truncated square pyramidal numbers". - Franklin T. Adams-Watters, Nov 29 2006
If n is the sum of d consecutive squares up to m^2, n = A000330(m) - A000330(m-d) = d*(m^2 - (d-1)*m + (d-1)*(2*d-1)/6) <=> m^2 - (d-1)*m = c := n/d - (d-1)*(2*d-1)/6 <=> m = (d-1)/2 + sqrt((d-1)^2/4 + c) which must be an integer. Moreover, A000330(x) >= x^3/3, so m and d can't be larger than (3*n)^(1/3). - M. F. Hasler, Jan 02 2024

Examples

			All squares (A000290: 0, 1, 4, 9, ...) are in this sequence, since "consecutive" in the definition means a subsequence without interruption, so a single term qualifies.
5 = 1^2 + 2^2 = A000330(2) is in this sequence, and similarly 13 = 2^2 + p3^2  = A000330(3) - A000330(1) and 14 = 1^2 + 2^2 + 3^2 = A000330(3), etc.
		

Crossrefs

Cf. A217843-A217850 (sums of consecutive powers 3 to 10).
Cf. A368570 (first of each pair of consecutive integers in this sequence).

Programs

  • Haskell
    import Data.Set (deleteFindMin, union, fromList); import Data.List (inits)
    a034705 n = a034705_list !! (n-1)
    a034705_list = f 0 (tail $ inits $ a000290_list) (fromList [0]) where
       f x vss'@(vs:vss) s
         | y < x = y : f x vss' s'
         | otherwise = f w vss (union s $ fromList $ scanl1 (+) ws)
         where ws@(w:_) = reverse vs
               (y, s') = deleteFindMin s
    -- Reinhard Zumkeller, May 12 2015
    
  • Mathematica
    nMax = 1000; t = {0}; Do[k = n; s = 0; While[s = s + k^2; s <= nMax, AppendTo[t, s]; k++], {n, Sqrt[nMax]}]; t = Union[t] (* T. D. Noe, Oct 23 2012 *)
  • PARI
    {is_A034705(n)= for(d=1,sqrtnint(n*3,3), my(b = (d-1)/2, s = n/d - (d-1)*(d*2-1)/6 + b^2); denominator(s)==denominator(b)^2 && issquare(s, &s) && return(b+s)); !n} \\ Return the index of the largest square of the sum (or 1 for n = 0) if n is in the sequence, else 0. - M. F. Hasler, Jan 02 2024
    
  • Python
    import heapq
    from itertools import islice
    def agen(): # generator of terms
        m = 0; h = [(m, 0, 0)]; nextcount = 1; v1 = None
        while True:
            (v, s, l) = heapq.heappop(h)
            if v != v1: yield v; v1 = v
            if v >= m:
                m += nextcount*nextcount
                heapq.heappush(h, (m, 1, nextcount))
                nextcount += 1
            v -= s*s; s += 1; l += 1; v += l*l
            heapq.heappush(h, (v, s, l))
    print(list(islice(agen(), 60))) # Michael S. Branicky, Jan 06 2024

Extensions

Terms a(1..10^4) double-checked with independent code by M. F. Hasler, Jan 02 2024

A368590 Numbers k such that all of k, k+1 and k+2 are the sums of consecutive squares.

Original entry on oeis.org

728, 1013, 2813, 3309, 4323, 4899, 12438, 21259, 23113, 31394, 35719, 37812, 38023, 111894, 143449, 194053, 418613, 418614, 487368, 535309, 2232593, 2452644, 2490669, 9226854, 17367998, 19637644, 20341453, 28553671, 33406839, 174398434, 468936719, 1468970139, 2136314464
Offset: 1

Views

Author

David A. Corneth, Dec 31 2023

Keywords

Comments

418613 is the smallest k such that k through k + 3 are the sums of consecutive squares.
After an idea by Allan C. Wechsler.
a(30)-a(33) were calculated using the b-file at A368570.

Examples

			728 is in the sequence via 728 = 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2 + 13^2, 729 = 27^2 and 730 = 10^2 + 11^2 + 12^2 + 13^2 + 14^2.
		

Crossrefs

Subsequence of A034705 and of A368570.

Programs

  • PARI
    \\ See PARI program
    
  • Python
    import heapq
    from itertools import islice
    def agen(): # generator of terms
        m = 1; h = [(m, 1, 1)]; nextcount = 2
        v1 = v2 = -1
        while True:
            (v, s, l) = heapq.heappop(h)
            if v != v1:
                if v2 + 2 == v1 + 1 == v: yield v2
                v2, v1 = v1, v
            if v >= m:
                m += nextcount*nextcount
                heapq.heappush(h, (m, 1, nextcount))
                nextcount += 1
            v -= s*s; s += 1; l += 1; v += l*l
            heapq.heappush(h, (v, s, l))
    print(list(islice(agen(), 33))) # Michael S. Branicky, Jan 01 2024
Showing 1-2 of 2 results.