login
A364143
a(n) is the minimal number of consecutive squares needed to sum to A216446(n).
0
2, 5, 3, 2, 2, 3, 10, 2, 7, 9, 12, 11, 6, 11, 14, 3, 11, 29, 14, 7, 23, 4, 49, 8, 24, 5, 17, 12, 38, 46, 27, 34, 6, 14, 22, 66, 11, 66, 14, 11, 6, 77, 36, 63, 96, 11, 50, 3, 19, 96, 52, 41, 66, 33, 11, 3, 14, 121, 66, 89, 34, 127, 51, 2, 86, 54, 181, 48, 8
OFFSET
1,1
EXAMPLE
a(8) = 7 is because 7 consecutive squares are needed to sum to A216446(8) = 595 = 6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2.
PROG
(Python)
is_palindrome = lambda n: str(n) == str(n)[::-1]
def g(L):
L2, squares, D = L*L, [x*x for x in range(0, L + 1)], {}
for i in range(1, L + 1):
for j in range(i + 1, L + 1):
candidate = sum(squares[i:j+1])
if candidate < L2 and is_palindrome(candidate):
if candidate in D:
D[candidate]= min(D[candidate], j-i-1)
else:
D[candidate] = j-i+1
return [D[k] for k in sorted(D.keys())]
print(g(1000))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Darío Clavijo, Jul 10 2023
STATUS
approved