A123999 Number of ordered ways of writing n as a sum of 4 squares of nonnegative numbers less than 4.
1, 4, 6, 4, 5, 12, 12, 4, 6, 16, 18, 12, 8, 16, 24, 12, 1, 12, 18, 12, 6, 4, 12, 12, 0, 0, 6, 4, 4, 0, 0, 4, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 0
Examples
a(0) = 1 because of the unique sum 0 = 0^2 + 0^2 + 0^2 + 0^2. a(1) = 4 because of the 4 permutations 1 = 0^2 + 0^2 + 0^2 + 1^2 = 0^2 + 0^2 + 1^2 + 0^2 = 0^2 + 1^2 + 0^2 + 0^2 = 1^2 + 0^2 + 0^2 + 0^2. a(4) = 5 because of 4 = 1^2 + 1^2 + 1^2 + 1^2 plus the 4 permutations of 4 = 0^2 + 0^2 + 0^2 + 2^2. a(16) = 1 because 16 = 2^2 + 2^2 + 2^2 + 2^2.
Programs
-
Mathematica
a[n_] := Total[ Length /@ Permutations /@ IntegerPartitions[n, {4}, Range[0, 3]^2]]; a /@ Range[0, 72] (* Giovanni Resta, Jun 13 2016 *)
Formula
a(n) = Card{(a,b,c,d) such that 0<=a,b,c,d<4 and a^2 + b^2 + c^2 + d^2 = n}.
Extensions
Corrected typo in third example Dave Zobel (dzobel(AT)alumni.caltech.edu), Mar 07 2009
a(16) and related example corrected by Giovanni Resta, Jun 13 2016
Comments