A Pythagorean triplet is a set of three natural numbers, a b
c, for which,
a
2 +
b
2 =
c
2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
--------------------------------------------------------------------------------------------------------------------------------------------------------------
import math
k=0for a in range (1,1000):
for b in range (a,1000):
c=math.sqrt(a*a+b*b)
if a+b+c==1000:
k=1
break
else:
b=b+1
continue
if k==1:
break
a=a+1
print ('%d*%d*%d=%d' %(a,b,c,a*b*c))