For the average to be n^2, the sum of the n squares must be n^3, so that's what we seek.
For n = 47, the sum of the squares from the 22nd square (484) through the 68th square (4624) is 103823, the 47th cube, so that, when divided by 47 to get the average, that average is 47^2.
When n is 2161, the sum of the squares from the 989th (978121) through the 3149th (9916201) square is 10091699281, the 2161st cube; when divided by 2161 to get the average that average is 2161^2.
The program output:
47 22 484 68 4624 103823
2161 989 978121 3149 9916201 10091699281
After running the program, entering 47,2161 into
Sloane's OEIS finds A189173, Integers m such that m^3 is the sum of squares of m consecutive integers. The list is preceded by zero and 1 and followed by 99359, 4568353, 210044879, 9657496081, 444034774847, 20415942146881, 938689303981679, 43159292041010353, 1984388744582494559, 91238722958753739361, 4194996867358089516047, 192878617175513363998801, 8868221393206256654428799, 407745305470312292739725953, 18747415830241159209372965039. The recursive formula is a(n) = 46*a(n1)  a(n2) where the a values are the n values of the puzzle.
The program:
DefDbl AZ
Dim squares(4000), sumsquares(4000), cubes(4000), crlf$
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
For i = 1 To 4000
squares(i) = i * i
sumsquares(i) = sumsquares(i  1) + squares(i)
cubes(i) = squares(i) * i
Next
For n = 2 To 4000
For subtr = 0 To 4000  n
cube = sumsquares(subtr + n)  sumsquares(subtr)
If cube = cubes(n) Then
Text1.Text = Text1.Text & n & Str(subtr + 1) & Str(squares(subtr + 1))
Text1.Text = Text1.Text & Str(subtr + n) & Str(squares(subtr + n)) & Str(cubes(n)) & crlf
End If
Next
Next
Text1.Text = Text1.Text & crlf & " done"
DoEvents
End Sub

Posted by Charlie
on 20190809 12:59:34 