A Pythagorean triplet is a set of three natural numbers, $a \lt b \lt 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$.
The Pythagorean triple $a, b, c$ with $a < b < c$ and $a + b + c = 1000$ is such that
$$a^2 + b^2 = c^2. \tag{1}$$
From $a + b + c = 1000$, one can make $c = 1000 – a – b$. So, substituting $c$ in equation $(1)$ we have:
$$a^2 + b^2 = (1000 – a – b)^2 = 1000^2 – 2000a – 2000b + 2ab + a^2 + b^2$$.
Cancelling like terms we get:
$$0 = 1000^2 – 2000a – 2000b + 2ab. \tag{2}$$
Since we know $a < b$, then we could say $a < 500$, thus the practical search is much less than 1000. Let's search for the correct $a$ and $b$ in a more programmatic way. Consider a loop where $a$ varies from 1 to 499, and for each $a$, $b$ varies from $a + 1$ to 500. Let's define a check for `if (1000000 - 2000*a - 2000*b + 2*a*b == 0)` which corresponds to the equation $(2)$. If the condition is true, then you have the needed $a$ and $b$ for the Pythagorean triple. After iterating, you will find that $a = 200$ and $b = 375$. You can then substitute these into $c = 1000 - a - b$ to find that $c = 425$. Now that we have $a$, $b$, and $c$ we can just solve for the product $abc$: $$abc = 200 \cdot 375 \cdot 425 = 31,875,000.$$
More Answers:
Sum Square Difference$10001$st Prime
Largest Product in a Series