proposed
approved
proposed
approved
editing
proposed
(Python)
from sympy.ntheory.primetest import is_square
from sympy.solvers.diophantine.diophantine import diop_DN
def A002349(n): return 0 if is_square(n) else next(b for a, b in diop_DN(n, 1)) # Chai Wah Wu, Feb 11 2025
approved
editing
reviewed
approved
proposed
reviewed
editing
proposed
T. D. Noe and Ray Chandler, <a href="/A002349/b002349.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from T. D. Noe)
approved
editing
Eric Chen, T. D. Noe and Ray Chandler, <a href="/A002349/b002349_2.txt">Table of n, a(n) for n = 1..2500010000</a> (first 1000 terms 1..1000 from T. D. Noe, terms 1001...10000 from Ray Chandler)
Eric Chen, <a href="/A002349/a002349.txt">Smallest solution of y >= 1 for x^2 - n*y^2 = 0, +-1, +-2, +-3, +-4, if exists, for n <= 25000</a> (solutions for the same n are sorted by y, but if the x^2 - n*y^2 = +-4 solutions are not primitive (i.e., they are the double of the (x, y) for x^2 - n*y^2 = +-1), they are in back of other solutions).
Eric Chen, <a href="/A002349/a002349_2.txt">PARI/GP program for the smallest solutions of y >= 1 for x^2 - n*y^2 = 0, +-1, +-2, +-3, +-4</a> (type "solvepell(n)" to get the solutions, the format of the solutions are "[x, y, z]" for x^2 - n*y^2 = z; solutions for the same n are sorted by y, but if the x^2 - n*y^2 = +-4 solutions are not primitive (i.e., they are the double of the (x, y) for x^2 - n*y^2 = +-1), they are in back of other solutions).
Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PellEquation.html">Pell equation</a>
<a href="http://www.jakebakermaths.org.uk/maths/jshtmlpellsolverbigintegerv10.html
<a href="http://math.fau.edu/richman/pell-m.htm">Pell equation solver for x^2-d*y^2 = 1</a>
<a href="http://www.numbertheory.org/php/pell.html">Pell equation solver for x^2-d*y^2 = +-1, +-2, +-3, +-4</a>
For n = 1, 2, 3, 4, 5, 6, 7, 8 the smallest solutions are (x,y) = (1, 0), (3, 2), (2, 1), (1, 0), (9, 4), (5, 2), (8, 3), (3, 1).
For n = 13 the smallest solution is (x,y) = (649, 180).
For n = 61 the smallest solution is (x,y) = (1766319049, 226153980).
For n = 92 the smallest solution is (x,y) = (1151, 120).
For n = 313 the smallest solution is (x,y) = (32188120829134849, 1819380158564160) (this is the equation which Bernard Frénicle de Bessy challenged John Wallis to solve).
For n = 991 the smallest solution is (x,y) = (379516400906811930638014896080, 12055735790331359447442538767).
For n = 4729494 the smallest solution is (109931986732829734979866232821433543901088049, 50549485234315033074477819735540408986340) (this is related to Archimedes's cattle problem).
(PARI)
pell(d)=
{
local(bb, b, len, m, x, y, z, x2, y2);
default(realprecision, 2000);
bb=contfrac(sqrt(d));
len=length(bb);
for(i=1, len,
b=vecextract(bb, 2^i-1);
m=contfracpnqn(b);
x=m[1, 1];
y=m[2, 1];
z=x^2-d*y^2;
if(z==1,
return([x, y])
);
if(z==-1,
x2=x*x+d*y*y;
y2=2*x*y;
return([x2, y2])
)
);
return([])
}
a(n)=if(issquare(n), 0, pell(n)[2]) \\ Eric Chen, Sep 27 2021
Cf. A002350 (values of x), A006702, A006703, A006704, A006705. See A033316, A033315, A033319 for records.
Cf. A033313, A033317 (square n's omitted).
Cf. A006702, A006703 (for x^2 - y^2 = +-1).
Cf. A077232, A077233 (for x^2 - y^2 = +-1, square n's omitted).
Cf. A006704, A006705 (for x^2 - y^2 = +-1, +-4).
Cf. A130226, A130227 (for x^2 - y^2 = -1).
Cf. A261247, A261248 (for x^2 - y^2 = 2).
Cf. A031396 (x^2 - y^2 = -1 is solvable).
Cf. A261246 (x^2 - y^2 = 2 is solvable).
Cf. A033316 (values d such that the smallest solution of x and y sets records).
Cf. A033315, A033319 (records for x and y).
Cf. A033314, A033318 (smallest value d such that the smallest solution of x and y is n).
nonn,nice,easy,changed
editing
approved
<a href="http://www.jakebakermaths.org.uk/maths/jshtmlpellsolverbigintegerv10.html
<a href="http://math.fau.edu/richman/pell-m.htm">Pell equation solver for x^2-d*y^2 = 1</a>
<a href="http://www.numbertheory.org/php/pell.html">Pell equation solver for x^2-d*y^2 = +-1, +-2, +-3, +-4</a>
proposed
editing
editing
proposed