%I #36 Apr 28 2020 11:06:14
%S 1,1,1,1,1,0,2,1,0,1,1,1,1,1,0,1,2,0,1,0,1,2,1,0,1,1,0,1,1,1,1,2,0,0,
%T 1,0,2,1,1,1,0,0,2,1,0,1,2,0,1,1,0,2,0,0,0,2,2,1,1,0,1,1,0,0,1,1,2,1,
%U 0,1,1,0,2,1,0,0,2,0,1,1,0,3,0,1,1,0,0,1,1,0,1,2,1,1,2,0,0,1,0,1,1,1
%N Number of ways to write n as the unordered sum of two triangular numbers (zero allowed).
%C Number of ways of writing n as a sum of a square and twice a triangular number (zeros allowed). - _Michael Somos_, Aug 18 2003
%C a(A020757(n))=0; a(A020756(n))>0; a(A119345(n))=1; a(A118139(n))>1. - _Reinhard Zumkeller_, May 15 2006
%C Also, number of ways to write 4n+1 as the unordered sum of two squares of nonnegative integers. - _Vladimir Shevelev_, Jan 21 2009
%C The average value of a(n) for n <= x is Pi/4 + O(1/sqrt(x)). - _Vladimir Shevelev_, Feb 06 2009
%H Reinhard Zumkeller, <a href="/A052343/b052343.txt">Table of n, a(n) for n = 0..10000</a>
%H V. Shevelev, <a href="https://arxiv.org/abs/0901.3102">Binary additive problems: recursions for numbers of representations</a>, arXiv:0901.3102 [math.NT], 2009-2013.
%H V. Shevelev, <a href="https://arxiv.org/abs/0902.1046">Binary additive problems: theorems of Landau and Hardy-Littlewood type</a>, arXiv:0902.1046 [math.NT], 2009-2012.
%F a(n) = ceiling(A008441(n)/2). - _Reinhard Zumkeller_, Nov 03 2009
%F G.f.: (Sum_{k>=0} x^(k^2 + k)) * (Sum_{k>=0} x^(k^2)). - _Michael Somos_, Aug 18 2003
%F Recurrence: a(n) = Sum_{k=1..r(n)} r(2n-k^2+k) - C(r(n),2) - a(n-1) - a(n-2) - ... - a(0), n>=1,a (0)=1, where r(n)=A000194(n+1) is the nearest integer to square root of n+1. For example, since r(6)=3, a(6) = r(12) + r(10) + r(6) - C(3,2) - a(5) - ... - a(0) = 4 + 3 + 3 - 3 - 0 - 1 - 1 - 1 - 1 - 1 = 2. - _Vladimir Shevelev_, Feb 06 2009
%F a(n) = A025426(8n+2). - _Max Alekseyev_, Mar 09 2009
%F a(n) = (A002654(4n+1) + A010052(4n+1)) / 2. - _Ant King_, Dec 01 2010
%F a(2*n + 1) = A053692(n). a(4*n + 1) = A259287(n). a(4*n + 3) = A259285(n). a(6*n + 1) = A260415(n). a(6*n + 4) = A260516(n) - _Michael Somos_, Jul 28 2015
%F a(3*n) = A093518(n). a(3*n + 1) = A121444(n). a(9*n + 2) = a(n). a(9*n + 5) = a(9*n + 8) = 0. - _Michael Somos_, Jul 28 2015
%F Convolution of A005369 and A010052. - _Michael Somos_, Jul 28 2015
%e G.f. = 1 + x + x^2 + x^3 + x^4 + 2*x^6 + x^7 + x^9 + x^10 + x^11 + ...
%p A052343 := proc(n)
%p local a,t1idx,t2idx,t1,t2;
%p a := 0 ;
%p for t1idx from 0 do
%p t1 := A000217(t1idx) ;
%p if t1 > n then
%p break;
%p end if;
%p for t2idx from t1idx do
%p t2 := A000217(t2idx) ;
%p if t1+t2 > n then
%p break;
%p elif t1+t2 = n then
%p a := a+1 ;
%p end if;
%p end do:
%p end do:
%p a ;
%p end proc: # _R. J. Mathar_, Apr 28 2020
%t Length[PowersRepresentations[4 # + 1, 2, 2]] & /@ Range[0, 101] (* _Ant King_, Dec 01 2010 *)
%t d1[k_]:=Length[Select[Divisors[k],Mod[#,4]==1&]];d3[k_]:=Length[Select[Divisors[k],Mod[#,4]==3&]];f[k_]:=d1[k]-d3[k];g[k_]:=If[IntegerQ[Sqrt[4k+1]],1/2 (f[4k+1]+1),1/2 f[4k+1]];g[#]&/@Range[0,101] (* _Ant King_, Dec 01 2010 *)
%t a[ n_] := Length @ Select[ Table[ Sqrt[n - i - i^2], {i, 0, Quotient[ Sqrt[4 n + 1] - 1, 2]}], IntegerQ]]; (* _Michael Somos_, Jul 28 2015 *)
%t a[ n_] := Length @ FindInstance[ {j >= 0, k >= 0, j^2 + k^2 + k == n}, {k, j}, Integers, 10^9]; (* _Michael Somos_, Jul 28 2015 *)
%o (PARI) {a(n) = if( n<0, 0, sum(i=0, (sqrtint(4*n + 1) - 1)\2, issquare(n - i - i^2)))}; /* _Michael Somos_, Aug 18 2003 */
%o (Haskell)
%o a052343 = (flip div 2) . (+ 1) . a008441
%o -- _Reinhard Zumkeller_, Jul 25 2014
%Y Cf. A000217, A052344, A052345 (greedy inverse), A052346, A052347, A052348, A053587, A056303, A056304.
%Y Cf. A053692, A093518, A121444, A259285, A259287, A260415, A260516.
%Y Cf. A005369, A010052.
%K nonn
%O 0,7
%A _Christian G. Bower_, Jan 23 2000