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.

A364143 a(n) is the minimal number of consecutive squares needed to sum to A216446(n).

This page as a plain text file.
%I A364143 #27 Aug 08 2023 18:04:30
%S A364143 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,
%T A364143 38,46,27,34,6,14,22,66,11,66,14,11,6,77,36,63,96,11,50,3,19,96,52,41,
%U A364143 66,33,11,3,14,121,66,89,34,127,51,2,86,54,181,48,8
%N A364143 a(n) is the minimal number of consecutive squares needed to sum to A216446(n).
%H A364143 Project Euler, <a href="https://projecteuler.net/problem=125">Problem 125: Palindromic Sums</a>.
%e A364143 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.
%o A364143 (Python)
%o A364143 is_palindrome = lambda n: str(n) == str(n)[::-1]
%o A364143 def g(L):
%o A364143   L2, squares, D = L*L, [x*x for x in range(0, L + 1)], {}
%o A364143   for i in range(1, L + 1):
%o A364143     for j in range(i + 1, L + 1):
%o A364143       candidate = sum(squares[i:j+1])
%o A364143       if candidate < L2 and is_palindrome(candidate):
%o A364143         if candidate in D:
%o A364143           D[candidate]= min(D[candidate], j-i-1)
%o A364143         else:
%o A364143           D[candidate] = j-i+1
%o A364143   return [D[k] for k in sorted(D.keys())]
%o A364143 print(g(1000))
%Y A364143 Cf. A216446, A034705, A180436, A267600.
%K A364143 nonn,base
%O A364143 1,1
%A A364143 _DarĂ­o Clavijo_, Jul 10 2023