07072018, 05:16 AM
Pell's equation (also called the Pell–Fermat equation) is the equation of the form of
X^2  nY^2 = 1
Where n is a given positive none square integer and integer solutions are sought for X and Y.
More information about this topic:
https://en.wikipedia.org/wiki/Pell%27s_equation
I personally make a note on this subject found on this MoHPC old forum and don't remember who posted this in the forum.
I found this very interesting and would like to share his clever program to solve this special equation.
Example: X^2  (3)Y^2 = 1
3 R/S > 2 X<>Y 1
Answer: X=2, Y=1
Remark: The list of the possible n is shown in the Wikipedia link.
Program: Pell's Equation
Gamo
X^2  nY^2 = 1
Where n is a given positive none square integer and integer solutions are sought for X and Y.
More information about this topic:
https://en.wikipedia.org/wiki/Pell%27s_equation
I personally make a note on this subject found on this MoHPC old forum and don't remember who posted this in the forum.
I found this very interesting and would like to share his clever program to solve this special equation.
Example: X^2  (3)Y^2 = 1
3 R/S > 2 X<>Y 1
Answer: X=2, Y=1
Remark: The list of the possible n is shown in the Wikipedia link.
Program: Pell's Equation
Code:
f 0
STO 0
SQRT
STO 1
INTG
STO 2
LSTx
FRAC
STO 3
1/x
INTG
STO 4
1
STO 5
STO 7
RCL 2
STO 6
RCL4
RCL 2
x
RCL 5
+
STO 2
RCL 1
/
RND
STO 7
RCL 3
1/x
FRAC
STO 3
1/x
INTG
STO 4
RCL 6
STO 5
RCL 2
ENTER
x
RCL 7
ENTER
x
RCL 0
x

1

X=0
GTO 51
GTO 16
RCL 7
RCL 2
GTO 00
Gamo