Created
January 29, 2025 09:39
-
-
Save igorvanloo/a7a164702902ffad722412ea0e31ef14 to your computer and use it in GitHub Desktop.
p142
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_sq(x): | |
sqrt = (x ** (1 / 2)) | |
if round(sqrt) ** 2 == x: | |
return True | |
return False | |
def compute(): | |
for b in range(1, 1000): | |
for a in range(b + 2, 1000, 2): | |
x = (a*a + b*b)//2 | |
y = a*a - x | |
if x < y: | |
break | |
else: | |
for c in range(int(math.sqrt(x)), a): | |
z = c*c - x | |
if z > y: | |
break | |
else: | |
if all([is_sq(x - z), is_sq(y + z), is_sq(y - z)]): | |
return x + y + z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment