login
a(n) is the number of ways to write n = i^2 + 2*j^2 + 3*k^2 with i,j,k >= 0.
3

%I #11 Sep 29 2023 16:13:17

%S 1,1,1,2,2,1,2,1,1,3,0,2,4,1,2,2,2,1,3,2,2,4,2,1,2,2,0,4,3,2,5,2,1,3,

%T 2,2,7,2,2,5,0,2,0,2,4,4,3,1,4,3,3,5,3,2,7,1,2,6,0,3,6,2,2,4,2,2,6,3,

%U 2,4,3,3,3,2,0,7,5,2,6,3,2,8,2,2,11,2,5,2,2,3,0,4,3,7,3,2,2,3,3

%N a(n) is the number of ways to write n = i^2 + 2*j^2 + 3*k^2 with i,j,k >= 0.

%H Robert Israel, <a href="/A366091/b366091.txt">Table of n, a(n) for n = 0..10000</a>

%F G.f. (1 + theta_3(0,z)) * (1 + theta_3(0,z^2)) * (1 + theta_3(0,z^3))/8 where theta_3 is a Jacobi theta function.

%e a(9) = 3 because 9 = 3^2 + 2*0^2 + 3*0^2 = 1^2 + 2*2^2 + 3*0^2 = 2^2 + 2*1^2 + 3*1^2.

%p g:= (1+JacobiTheta3(0,z))*(1+JacobiTheta3(0,z^2))*(1+JacobiTheta3(0,z^3))/8:

%p S:= series(g,z,101):

%p seq(coeff(S,z,j),j=0..100);

%o (Python)

%o from itertools import count

%o from sympy.ntheory.primetest import is_square

%o def A366091(n):

%o c = 0

%o for k in count(0):

%o if (a:=3*k**2)>n:

%o break

%o for j in count(0):

%o if (b:=a+(j**2<<1))>n:

%o break

%o if is_square(n-b):

%o c += 1

%o return c # _Chai Wah Wu_, Sep 29 2023

%Y Cf. A028594 (allows any integer i,j,k), A055042 (a(n) = 0)

%K nonn

%O 0,4

%A _Robert Israel_, Sep 28 2023