Project Euler
Problem 9: Special Pythagorean Triplet

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 a b c .


Runtime: 0
Average: 0 Runs: 0
SD: 0 ms
Max: 0
Min: 1000

I use Euclid's formula for generating Pythagorean triples:

a = m 2 - n 2 , b = 2 m n , c = m 2 + n 2

With this, I run a nested set of for loops, each counting up to 25 to test if the sum of my three numbers is 1,000.