A218706 Number of nonnegative integer solutions to x^2 + 2y^2 <= n^2.
1, 2, 5, 9, 12, 19, 27, 33, 42, 54, 66, 77, 91, 105, 120, 138, 156, 175, 197, 218, 240, 263, 287, 314, 339, 367, 398, 430, 459, 493, 526, 556, 595, 637, 670, 709, 752, 794, 833, 878, 921, 965, 1018, 1065, 1112, 1163, 1215, 1266, 1317, 1370, 1433, 1492, 1544
Offset: 0
Keywords
Examples
There are 5 solutions for n=2, namely (0,0), (0,1), (1,1), (1,0) and (2,0), so a(2) = 5.
Programs
-
JavaScript
for (i=0;i<50;i++) { c=0; for (a=0;a<=i;a++) for (b=0;b<=i;b++) if (Math.pow(a,2)+2*Math.pow(b,2)<=Math.pow(i,2)) c++; document.write(c+", "); }
-
Mathematica
nn = 50; t = Sort[Select[Flatten[Table[x^2 + 2*y^2, {x, 0, nn}, {y, 0, nn}]], # <= nn^2 &]]; Table[Count[t, ?(# <= n^2 &)], {n, 0, nn}] (* _T. D. Noe, Nov 06 2012 *)