Back to Problems

Problem 9: Special Pythagorean Triplet

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$.

Solution Approach

To find three natural numbers $a$, $b$, and $c$ such that $a^2 + b^2 = c^2$ and $a + b + c = 1000$, we can use the relationship $c = 1000 - a - b$ to eliminate one variable and solve in terms of $a$ and $b$.

Substituting $c = 1000 - a - b$ into $a^2 + b^2 = c^2$ gives:

$$a^2 + b^2 = (1000 - a - b)^2$$

Expanding and simplifying leads to:

$$a^2 + b^2 = 1000^2 + a^2 + b^2 - 2000a - 2000b + 2ab$$

Canceling terms and rearranging for $b$ gives:

$$b = \frac{1000(1000 - 2a)}{2(1000 - a)}$$

We can now iterate possible values of $a$ and check whether $b$ is an integer.

In terms of python:


for a in range(1, 1000 // 3):
    b = (1000 * (1000 - 2 * a)) / (2 * (1000 - a))
    if b.is_integer():
        b = int(b)
        c = 1000 - a - b
        print(a * b * c)
        break

Explained line by line:

Running the above code leads to an answer of $31875000$.