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 [10]:
# YOUR CODE HERE
In [2]:
for x in range(1,1000):#iterates through x (up to 999 since any a,b,c sum over that couldnt include all natural numbers)
for y in range(x+1,1000): # for every x iterates through y greater than x since a<b
a=x
b=y #not necessary but keeps in same notation as question
c=(x**2+y**2)**(1/2) #assigns c**2=a**2+b**2
if a+b+c==1000: #if sum equals 1000 prints product
print(a*b*c)
In [ ]:
# This cell will be used for grading, leave it at the end of the notebook.