24 lines
585 B
Python
24 lines
585 B
Python
|
|
def is_pythagorean_triplet(a, b, c):
|
||
|
|
if (a * a + b * b) == (c * c):
|
||
|
|
return True
|
||
|
|
else:
|
||
|
|
return False
|
||
|
|
|
||
|
|
tripletFound = False
|
||
|
|
|
||
|
|
for i in range(1,500):
|
||
|
|
for j in range(1,500):
|
||
|
|
for k in range(1,500):
|
||
|
|
if is_pythagorean_triplet(i, j, k):
|
||
|
|
print("triplet:",i,j,k)
|
||
|
|
if i+j+k == 1000:
|
||
|
|
print("The product of abc is: " + str(i*j*k))
|
||
|
|
tripletFound = True
|
||
|
|
if tripletFound:
|
||
|
|
break
|
||
|
|
if tripletFound:
|
||
|
|
break
|
||
|
|
if tripletFound:
|
||
|
|
break
|
||
|
|
|