Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pythagorean(leg, p):
- hypotenuse = int(p/3)
- leg2 = p - hypotenuse - leg
- while True:
- if (leg ** 2 + leg2 ** 2) == hypotenuse ** 2:
- return True
- leg2 -= 1
- hypotenuse += 1
- if hypotenuse == p:
- return False
- best, bestx, runningtotal = 0, 0, 0
- for x in range(3, 1001):
- print(x, best)
- for y in range(int(x/3)+1):
- if pythagorean(y, x):
- runningtotal += 1
- if runningtotal > best:
- best = runningtotal
- bestx = x
- runningtotal = 0
- print(bestx)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement