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.

A379857 Number of values of k for which n can be written as a sum of k distinct positive squares.

This page as a plain text file.
%I A379857 #36 Aug 26 2025 10:23:30
%S A379857 1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,1,1,0,0,0,2,2,0,0,2,2,0,0,0,
%T A379857 1,1,1,1,1,1,1,2,1,0,0,2,2,0,0,2,3,1,1,2,2,1,1,1,1,1,0,2,2,1,1,3,3,0,
%U A379857 1,1,2,1,0,1,3,3,0,1,2,2,1,3,2,1,2
%N A379857 Number of values of k for which n can be written as a sum of k distinct positive squares.
%C A379857 It appears that a(n) is not bounded, but grows very slowly.
%C A379857 First differs from A033461 at n=62 which can be written as A033461(62) = 3 sums of squares, but among them only a(62) = 2 different numbers of squares.
%H A379857 Luke E. Holland, <a href="/A379857/b379857.txt">Table of n, a(n) for n = 0..10000</a>
%H A379857 Paul T. Bateman, Adolf J. Hildebrand, and George B. Purdy, <a href="http://matwbn.icm.edu.pl/ksiazki/aa/aa67/aa6745.pdf">Sums of distinct squares</a>, Acta Arithmetica 67 (1994), pp. 349-380.
%F A379857 a(n) < (3n)^(1/3) for n > 0. I conjecture that a(n) ~ (3n)^(1/3). - _Charles R Greathouse IV_, Feb 05 2025
%e A379857 a(0) = 1, as it is the sum of 0 squares.
%e A379857 a(25) = 2, as 25 = 5^2 = 4^2 + 3^2, so k can be 1 or 2.
%e A379857 a(90) = 4, as 90 = 9^2 + 3^2 = 8^2 + 5^2 + 1^2 = 8^2 + 4^2 + 3^2 + 1^2 = 6^2 + 5^2 + 4^2 + 3^2 + 2^2, so k can be 2, 3, 4 or 5.
%o A379857 (Python)
%o A379857 MAXSQUARE = 500
%o A379857 possibleSums = {i: [[], []] for i in range(MAXSQUARE ** 2 + 1)}
%o A379857 possibleSums[0] = [[0],[0]]
%o A379857 for val in range(MAXSQUARE ** 2):
%o A379857     for posSquare in range(len(possibleSums[val][0])):
%o A379857         newSum = possibleSums[val][0][posSquare] + 1
%o A379857         curr = possibleSums[val][1][posSquare] + 1
%o A379857         while val + curr ** 2 <= MAXSQUARE ** 2:
%o A379857             nVal = val + curr ** 2
%o A379857             if newSum not in possibleSums[nVal][0]:
%o A379857                 possibleSums[nVal][0].append(newSum)
%o A379857                 possibleSums[nVal][1].append(curr)
%o A379857             else:
%o A379857                 index = possibleSums[nVal][0].index(newSum)
%o A379857                 if curr < possibleSums[nVal][1][index]:
%o A379857                     possibleSums[nVal][1][index] = curr
%o A379857             curr += 1
%o A379857 posKVals = tuple([len(possibleSums[i][0]) for i in range(MAXSQUARE ** 2 + 1)])
%o A379857 (Python)
%o A379857 from itertools import count
%o A379857 from sympy.solvers.diophantine.diophantine import power_representation
%o A379857 def A379857(n):
%o A379857     if n == 0: return 0
%o A379857     c = 0
%o A379857     for i in count(1):
%o A379857         if i*(i+1)*((i<<1)+1)>6*n:
%o A379857             break
%o A379857         if any(len(set(t))==i for t in power_representation(n,2,i)):
%o A379857             c += 1
%o A379857     return c # _Chai Wah Wu_, Jan 28 2025
%Y A379857 Cf. A001422 (indices of 0's), A003995 (indices of not 0).
%Y A379857 Cf. A379831 (indices of records).
%K A379857 nonn,changed
%O A379857 0,26
%A A379857 _Luke E. Holland_, Jan 04 2025