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.
Have $a + b + c = 1000$ and $a^2 + b^2 = c^2$
We can reduce this with a little algebra:
$$a^2 = c^2 - b^2 = (c + b)(c - b)$$So $$a^2 = (1000 - a)(1000 - a - 2b)$$
Simplifying: $$ a + b - \frac{ab}{1000} = 500 \\ b = \frac{1000 (500 - a)}{1000 - a} $$
In [7]:
for i in range(2, 500):
if 1000*(500 - i) % (1000 - i) == 0:
a = i
b = (1000*(500 - i))/(1000 - i)
c = 1000 - a - b
break
print "a:",a, "b:",b, "c:",c
print a**2 + b**2, c**2
print a*b*c
In [ ]: