9.py
576 Bytes
#!/usr/bin/python
import sys;
import math;
def isPythagorean(a,b,c):
if((a**2 + b**2) == c**2):
return True;
return False;
def getTriplet(threshold):
for a in range (1,threshold):
for b in range (1,threshold):
for c in range (1,threshold):
if(isPythagorean(a,b,c)):
if(a+b+c == threshold):
return [a,b,c];
resultArray = getTriplet(int(sys.argv[1]));
print "Result is: a=" + str(resultArray[0]) + " b=" + str(resultArray[1]) + " c=" + str(resultArray[2]);
print "Product is " str(int(resultArray[0]) * int(resultArray[1]) * int(resultArray[2]));