For first try, compute
n = (x2-1)/y2, (x2+1)/y2
for x, y less than 1000,
and find the solutions for n less than 100 which does not have the square factors.
When we find the solution of x2 - ny2 = -1,
then we can construct the solution for x2 - ny2 = +1 by
X = x2 + ny2
Y = 2xy
10 ' pell1 20 dim M(100) 30 for I=2 to 100 40 if moeb(I)=0 then M(I)=1 else M(I)=0 50 next I 60 ' 70 for X=1 to 1000:X2=X^2 80 for Y=1 to 1000:Y2=Y^2 90 if (X2+1)@Y2=0 then W=(X2+1)\Y2 else 120 100 if or{W<1,W>=100} then 120 110 if M(W)=0 then print W;X;Y;X2-W*Y2:M(W)=1 120 if (X2-1)@Y2=0 then W=(X2-1)\Y2 else 150 130 if or{W<1,W>=100} then 150 140 if M(W)=0 then print W;X;Y;X2-W*Y2:M(W)=1 150 next Y 160 next X 170 ' 180 for I=2 to 100 190 if M(I)=0 then print I; 200 next I
moeb(I) in line 40 denotes the moebius function, which returns 0 when I has square factors.
n | x | y | x2 - ny2 |
---|---|---|---|
2 | 1 | 1 | -1 |
3 | 2 | 1 | 1 |
5 | 2 | 1 | -1 |
6 | 5 | 2 | 1 |
7 | 8 | 3 | 1 |
10 | 3 | 1 | -1 |
11 | 10 | 3 | 1 |
13 | 18 | 5 | -1 |
14 | 15 | 4 | 1 |
15 | 4 | 1 | 1 |
17 | 4 | 1 | -1 |
19 | 170 | 39 | 1 |
21 | 55 | 12 | 1 |
22 | 197 | 42 | 1 |
23 | 24 | 5 | 1 |
26 | 5 | 1 | -1 |
29 | 70 | 13 | -1 |
30 | 11 | 2 | 1 |
33 | 23 | 4 | 1 |
34 | 35 | 6 | 1 |
35 | 6 | 1 | 1 |
37 | 6 | 1 | -1 |
38 | 37 | 6 | 1 |
39 | 25 | 4 | 1 |
41 | 32 | 5 | -1 |
42 | 13 | 2 | 1 |
47 | 48 | 7 | 1 |
51 | 50 | 7 | 1 |
53 | 182 | 25 | -1 |
55 | 89 | 12 | 1 |
57 | 151 | 20 | 1 |
58 | 99 | 13 | -1 |
59 | 530 | 69 | 1 |
62 | 63 | 8 | 1 |
65 | 8 | 1 | -1 |
66 | 65 | 8 | 1 |
70 | 251 | 30 | 1 |
74 | 43 | 5 | -1 |
77 | 351 | 40 | 1 |
78 | 53 | 6 | 1 |
79 | 80 | 9 | 1 |
82 | 9 | 1 | -1 |
83 | 82 | 9 | 1 |
85 | 378 | 41 | -1 |
87 | 28 | 3 | 1 |
89 | 500 | 53 | -1 |
95 | 39 | 4 | 1 |
In this primitive search, we cannot find the solutions for n equal
31, 43, 46, 61, 67, 69, 71, 73, 86, 91, 93, 94, 97
Next, expand the search range for x, y up to 10000.
10 ' pell2 20 input N:if moeb(N)=0 then 20 30 ' 40 for Y=2 to 10000:Y2=Y^2 50 W=N*Y2-1:X=isqrt(W):if res=0 then print N;X;Y;W-N*Y2:end 60 W=N*Y2+1:X=isqrt(W):if res=0 then print N;X;Y;W-N*Y2:end 70 next Y
Results are following.
n | x | y | x2 - ny2 |
---|---|---|---|
31 | 1520 | 273 | 1 |
43 | 3482 | 531 | 1 |
46 | 24335 | 3588 | 1 |
61 | 29718 | 3805 | -1 |
67 | 48842 | 5967 | 1 |
69 | 7775 | 936 | 1 |
71 | 3480 | 413 | 1 |
73 | 1068 | 125 | -1 |
86 | 10405 | 1122 | 1 |
91 | 1574 | 165 | 1 |
93 | 12151 | 1260 | 1 |
97 | 5604 | 569 | -1 |
Extend the upper bound for y up to 109 and try to find n=94.
94 : 2143295 , 221064 : 1
So, for all n less than 100, we could find the solutions x, y.
previous | index | next |
---|