login
Numbers that are the sum of nine squares in one or more ways.
4

%I #6 Aug 05 2021 07:18:02

%S 9,12,15,17,18,20,21,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,

%T 39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,

%U 62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80

%N Numbers that are the sum of nine squares in one or more ways.

%H Sean A. Irvine, <a href="/A345498/b345498.txt">Table of n, a(n) for n = 1..1000</a>

%e 12 is a term because 12 = 1^2 + 1^2 + 1^2 + 1^2 + 1^2 + 1^2 + 1^2 + 1^2 + 2^2.

%o (Python)

%o from itertools import combinations_with_replacement as cwr

%o from collections import defaultdict

%o keep = defaultdict(lambda: 0)

%o power_terms = [x**2 for x in range(1, 1000)]

%o for pos in cwr(power_terms, 9):

%o tot = sum(pos)

%o keep[tot] += 1

%o rets = sorted([k for k, v in keep.items() if v >= 1])

%o for x in range(len(rets)):

%o print(rets[x])

%Y Cf. A003332, A345488, A345499, A345508.

%K nonn

%O 1,1

%A _David Consiglio, Jr._, Jun 19 2021