OFFSET
1,3
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)(2d-1)/6 <=> m^2 - (d-1)m = c := n/d - (d-1)(2d-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 (3n)^(1/3). - M. F. Hasler, Jan 02 2024
LINKS
EXAMPLE
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.
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 *)
PROG
(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
(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
CROSSREFS
Cf. A368570 (first of each pair of consecutive integers in this sequence).
KEYWORD
nonn
AUTHOR
EXTENSIONS
Terms a(1..10^4) double-checked with independent code by M. F. Hasler, Jan 02 2024
STATUS
approved