https://projecteuler.net/problem=9
A Pythagorean triplet is a set of three natural numbers, $a < b < c$, for which,
$$a^2 + b^2 = c^2$$For example, $3^2 + 4^2 = 9 + 16 = 25 = 5^2$.
There exists exactly one Pythagorean triplet for which $a + b + c = 1000$. Find the product abc.
In [24]:
import random
a = random.randint(1, 1000)
b = random.randint(1, 1000)
c = random.randint(1, 1000)
while a**2 + b**2 != (1000 - a - b)**2:
a = random.randint(1, 1000)
b = random.randint(1, 1000)
else:
print(a * b * (1000 - a - b))
In [20]:
# This cell will be used for grading, leave it at the end of the notebook.