Solution to problem 66 in Python

This commit is contained in:
David Doblas Jiménez 2023-09-08 18:58:07 +02:00
parent b1433cbc84
commit 9b0f077d2b

38
src/Python/Problem066.py Normal file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python
"""
Created on 08 Sep 2023
@author: David Doblas Jiménez
@email: daviddoji@pm.me
Solution for problem 066 from Project Euler
https://projecteuler.net/problem=66
"""
from sympy import simplify
from sympy.abc import t, x, y
from sympy.solvers.diophantine.diophantine import diop_quadratic
from utils import timeit
@timeit("Problem 066")
def compute():
"""
# Statement
"""
max_d, max_x = 0, 0
for d in range(2, 1000):
solve = diop_quadratic(x**2 - d * y**2 - 1, t)
for i in solve:
sol = simplify(i.subs({t: 0}))
xx = sol[0]
if xx > max_x:
max_x = xx
max_d = d
return max_d
if __name__ == "__main__":
print(f"Result for Problem 066 is {compute()}")