OFFSET
1,3
COMMENTS
This equation is a Pellian equation of the form x^2 - D^2*y^2 = N. A042965 covers the case D=1.
This sequence is also numbers that are congruent to {0,1,4,5,9,12,13} mod 16.
LINKS
Bruno Berselli, Table of n, a(n) for n = 1..1000
Index entries for linear recurrences with constant coefficients, signature (1,0,0,0,0,0,1,-1).
FORMULA
G.f.: x^2*(x+1)*(3*x+1)*(x^2-x+1)*(x^2+1) / ((x-1)^2*(x^6+x^5+x^4+x^3+x^2+x+1)).
a(n) ~ 16*n/7. - Stefano Spezia, Apr 08 2024
EXAMPLE
For N=33, the equation x^2 - 4*y^2 = 33 has solutions (X,Y) = (7,2) and (17,8).
PROG
(PARI)
\\ Values of n for which the equation x^2 - d^2*y^2 = n has integer solutions.
\\ e.g. allpellsq(2, 20) gives [0, 1, 4, 5, 9, 12, 13, 16, 17, 20]
allpellsq(d, nmax) = {
local(v=[0], n, w);
for(n=1, nmax,
w=pellsq(d, n);
if(#w>0, v=concat(v, n))
);
v
}
\\ All integer solutions to x^2-d^2*y^2=n.
\\ e.g. pellsq(5, 5200) gives [265, 51; 140, 24; 85, 9]
pellsq(d, n) = {
local(m=Mat(), f, x, y);
fordiv(n, f,
if(f*f>n, break);
if((n-f^2)%(2*f*d)==0,
y=(n-f^2)\(2*f*d);
x=d*y+f;
m=concat(m, [x, y]~)
)
);
m~
}
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Colin Barker, Oct 13 2013
STATUS
approved