OFFSET
1,16
COMMENTS
For (x, y) to be a solution to the more general equation x^2 - d^2*y^2 = n, it can be shown that n-f^2 must be divisible by 2*f*d, where f is a divisor of n not exceeding sqrt(n). Then y = (n-f^2)/(2*f*d) and x = d*y+f.
LINKS
Bruno Berselli, Table of n, a(n) for n = 1..1000
EXAMPLE
a(7) = 1 because x^2 - 9*y^2 = 7 has one nonnegative integer solution: (x,y) = (4,1).
PROG
(PARI) a(n) = sumdiv(n, f, f^2<=n && (n-f^2)%(6*f)==0);
(Magma) d:=3; solutions:=func<i | [f: f in Divisors(i) | f le Isqrt(i) and IsZero((i-f^2) mod (2*f*d))]>; [#solutions(n): n in [1..100]]; // Bruno Berselli, Oct 15 2013
CROSSREFS
KEYWORD
nonn
AUTHOR
Colin Barker, Oct 14 2013
STATUS
approved