%I #56 Feb 13 2024 08:16:18
%S 1,1,2,1,4,0,1,6,4,0,1,8,12,0,2,1,10,24,8,4,0,1,12,40,32,6,8,0,1,14,
%T 60,80,24,24,0,0,1,16,84,160,90,48,24,0,0,1,18,112,280,252,112,96,0,4,
%U 2,1,20,144,448,574,312,240,64,12,4,0,1,22,180,672,1136,840,544,320,24,30,8,0
%N Array: T(d,n) = number of ways of writing n as a sum of d squares, read by ascending antidiagonals.
%C This is the transpose of the array in A286815.
%C T(d,n) is divisible by 2d for any n != 0 iff d is a power of 2. - _Jianing Song_, Sep 05 2018
%H Alois P. Heinz, <a href="/A122141/b122141.txt">Antidiagonals d = 1..141, flattened</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Sum_of_squares_function">Sum of squares function</a> (transposed)
%H <a href="/index/Su#ssq">Index entries for sequences related to sums of squares</a>
%F T(n,n) = A066535(n). - _Alois P. Heinz_, Jul 16 2014
%e Array T(d,n) with rows d = 1,2,3,... and columns n = 0,1,2,3,... reads
%e 1 2 0 0 2 0 0 0 0 2 0 ...
%e 1 4 4 0 4 8 0 0 4 4 8 ...
%e 1 6 12 8 6 24 24 0 12 30 24 ...
%e 1 8 24 32 24 48 96 64 24 104 144 ...
%e 1 10 40 80 90 112 240 320 200 250 560 ...
%e 1 12 60 160 252 312 544 960 1020 876 1560 ...
%e 1 14 84 280 574 840 1288 2368 3444 3542 4424 ...
%e 1 16 112 448 1136 2016 3136 5504 9328 12112 14112 ...
%e 1 18 144 672 2034 4320 7392 12672 22608 34802 44640 ...
%e 1 20 180 960 3380 8424 16320 28800 52020 88660 129064 ...
%p A122141 := proc(d,n) local i,cnts ; cnts := 0 ; for i from -trunc(sqrt(n)) to trunc(sqrt(n)) do if n-i^2 >= 0 then if d > 1 then cnts := cnts+procname(d-1,n-i^2) ; elif n-i^2 = 0 then cnts := cnts+1 ; fi ; fi ; od ; cnts ;
%p end:
%p for diag from 1 to 14 do for n from 0 to diag-1 do d := diag-n ; printf("%d,",A122141(d,n)) ; od ; od;
%p # second Maple program:
%p A:= proc(d, n) option remember; `if`(n=0, 1, `if`(n<0 or d<1, 0,
%p A(d-1, n) +2*add(A(d-1, n-j^2), j=1..isqrt(n))))
%p end:
%p seq(seq(A(h-n, n), n=0..h-1), h=1..14); # _Alois P. Heinz_, Jul 16 2014
%t Table[ SquaresR[d - n, n], {d, 1, 12}, {n, 0, d - 1}] // Flatten (* _Jean-François Alcover_, Jun 13 2013 *)
%t A[d_, n_] := A[d, n] = If[n==0, 1, If[n<0 || d<1, 0, A[d-1, n] + 2*Sum[A[d-1, n-j^2], {j, 1, Sqrt[n]}]]]; Table[A[h-n, n], {h, 1, 14}, {n, 0, h-1}] // Flatten (* _Jean-François Alcover_, Feb 28 2018, after _Alois P. Heinz_ *)
%o (Python)
%o from sympy.core.power import isqrt
%o from functools import cache
%o @cache
%o def T(d, n):
%o if n == 0: return 1
%o if n < 0 or d < 1: return 0
%o return T(d-1, n) + sum(T(d-1, n-(j**2)) for j in range(1, isqrt(n)+1)) * 2 # _Darío Clavijo_, Feb 06 2024
%Y Cf. A066535, A286815.
%Y Cf. A000122 (1st row), A004018 (2nd row), A005875 (3rd row), A000118 (4th row), A000132 (5th row), A000141 (6th row), A008451 (7th row), A000143 (8th row), A008452 (9th row), A000144 (10th row), A008453 (11th row), A000145 (12th row), A276285 (13th row), A276286 (14th row), A276287 (15th row), A000152 (16th row).
%Y Cf. A005843 (2nd column), A046092 (3rd column), A130809 (4th column).
%Y Cf. A010052 (1st row divides 2), A002654 (2nd row divides 4), A046897 (4th row divides 8), A008457 (8th row divides 16), A302855 (16th row divides 32), A302857 (32nd row divides 64).
%K nonn,tabl
%O 1,3
%A _R. J. Mathar_, Oct 29 2006