OFFSET
1,2
COMMENTS
A number can be written as a^2+b^2 if and only if it has no prime factor congruent to 3 (mod 4) raised to an odd power.
A number can be written as a^2+2*b^2 if and only if it has no prime factor congruent to 5 (mod 8) or 7 (mod 8) raised to an odd power.
A number can be written as a^2+3*b^2 if and only if it has no prime factor congruent to 2 (mod 3) raised to an odd power.
A number can be written as a^2+7*b^2 if and only if it has no prime factor congruent to 3 (mod 7) or 5 (mod 7) or 6 (mod 7) raised to an odd power. Also the power of 2 should not be 1, if it can be written in the form a^2+7*b^2.
a(n) = 0 if and only if n is a square. - Charles R Greathouse IV, Sep 11 2012
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
N:= 100: # for a(1)..a(N)
m:= floor(sqrt(N)):
V:= Vector(N, i->{}):
for a from 0 to m do
for b from 1 to m do
for k from 1 to floor((N-a^2)/b^2) do
x:= a^2 + k*b^2;
V[x]:= V[x] union {k};
od od od:
for i from 1 to N do
if issqr(i) then V[i]:=0 else V[i]:= nops(V[i]) fi
od:
convert(V, list); # Robert Israel, Mar 06 2025
PROG
(PARI) for(n=1, 100, sol=0; for(k=1, n, for(x=0, n, if(issquare(n-k*x*x)&&n-k*x*x>=0, sol++; break))); if(issquare(n), print1(0", "), print1(sol", "))) /* V. Raman, Oct 16 2012 */
CROSSREFS
KEYWORD
nonn,look
AUTHOR
V. Raman, Sep 07 2012
STATUS
approved
