Let s(k) denote the sum of the first k terms of the series. Now s(1)=1^2, s(3)=1^2+2^2, and in general s(k(k+1)/2)=1^2 + 2^2 + . . . + k^2 -->
s(k(k+1)/2) = k(k+1)(2k+1)/6
Letting n=k(k+1)/2 --> s(n) = n*sqrt(8n+1)/3 when 8n+1 is a perfect square and n is a triangular number.
Let m denote the largest triangular number less than or equal to n. So s(m)=m*sqrt(8m+1)/3 and m=j(j+1)/2 for some positive integer j. Now m is the j_th triangular number --> j^2 + j - 2m = 0 --> j = (-1 + sqrt(8m+1))/2 -->
j = [ (-1+sqrt(8n+1))/2 ]
where [w] denotes the greatest integer less than or equal to w.
But s(n) = s(m) + (n-m)(j+1). Substituting the above equations for s(m) and m, and then simplifying yields
s(n) = (j + 1)(6n - j^2 - 2j)/6.