|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/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]));
|