%I #44 Nov 16 2022 08:53:05
%S 0,0,1,0,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,2,0,3,0,0,1,1,3,0,0,1,0,1,0,
%T 0,3,1,1,0,1,3,0,1,1,1,2,0,1,2,0,1,1,2,1,1,1,1,2,1,0,3,1,1,1,0,3,1,1,
%U 0,0,2,0,1,1,1,1,1,5,0,1,1,0,1,0,0,3,0,3,1,0,3,1,3,1,3,3,0,1,0,0,3,0,2,0,1
%N Number of ways the n-th triangular number T(n) = A000217(n) can be written as the sum of two positive triangular numbers.
%C The order doesn't matter. 21 = 6+15 = 15+6 are not counted as distinct solutions. - _N. J. A. Sloane_, Feb 22 2020
%H Alois P. Heinz, <a href="/A309332/b309332.txt">Table of n, a(n) for n = 1..20000</a>
%F a(n) > 0 <=> n in { A012132 }.
%F a(n) = 0 <=> n in { A027861 }.
%F a(n) = 1 <=> n in { A108769 }.
%e a(3) = 1: 2*3/2 + 2*3/2 = 3*4/2.
%e a(21) = 2: 6*7/2 + 20*21/2 = 12*13/2 + 17*18/2 = 21*22/2.
%e a(23) = 3: 9*10/2 + 21*22/2 = 11*12/2 + 20*21/2 = 14*15/2 + 18*19/2 = 23*24/2.
%p a:= proc(n) local h, j, r, w; h, r:= n*(n+1), 0;
%p for j from n-1 by -1 do w:= j*(j+1);
%p if 2*w<h then break fi;
%p if issqr((h-w)*4+1) then r:=r+1 fi
%p od; r
%p end:
%p seq(a(n), n=1..120);
%t a[n_] := Module[{h = n(n+1), j, r = 0, w}, For[j = n-1, True, j--, w = j(j+1); If[2w < h, Break[]]; If[ IntegerQ[Sqrt[4(h-w)+1]], r++]]; r];
%t Table[a[n], {n, 1, 120}] (* _Jean-François Alcover_, Nov 16 2022, after _Alois P. Heinz_ *)
%Y Cf. A000217, A001652, A012132, A027861, A046080 (the same for squares), A053141, A062301 (the same for primes), A108769, A309507.
%K nonn
%O 1,21
%A _Alois P. Heinz_, Aug 01 2019
|