Consider quadratic Diophantine equations of the form:(adsbygoogle = window.adsbygoogle || []).push({});

x– D^{2}y= 1^{2}

For example, when D=13, the minimal solution inxis 6492 – 13×1802 = 1.

It can be assumed that there are no solutions in positive integers when D is square.

By finding minimal solutions inxfor D = {2, 3, 5, 6, 7}, we obtain the following:

3^{2}– 2×2^{2}= 1

2^{2}– 3×1^{2}= 1

9^{2}– 5×4^{2}= 1

5^{2}– 6×2^{2}= 1

8^{2}– 7×3^{2}= 1

Hence, by considering minimal solutions inxfor D ≤ 7, the largestxis obtained when D=5.

Find the value of D ≤ 1000 in minimal solutions ofxfor which the largest value ofxis obtained.

Any idea how to solve this ?

I made a code but its slow. I find some information about the general solution but I didnt understand it much.

http://mathworld.wolfram.com/PellEquation.html

I noticed that theres 427 -D- values which their minimal x values are larger then 10**5. So I dont think brute force can give the solution.Code (Python):import time

start = time.perf_counter()

Number = [i for i in range(2,1001)]

Sq1 = [i**2 for i in range(2,int(1001**0.5))]

for i in Sq1:

Number.remove(i)

D_high_values =[]

x_initial = 3

for D in Number:

for x in range(2,10**5):

y = ((x**2-1)/D)

k = str(y**0.5)

if k[-1] == "0" and k[-2] ==".": #testing if the square root is integer

if x_initial < x:

x_initial = x

break

else:

D_high_values.append(D) #collecting values that have larger x value then 10**5

print(D_high_values)

print(x_initial) #highest minimal x up to 10**5

end = time.perf_counter()

print("Time to solve:",end-start)

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Python Project Euler- Problem 66

Have something to add?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**