ProjectEuler.net
 |   |   |   |   |   |   |   |   |   | 

Project Euler.net Answers

Problem 9

Solved on 2/26/2008

A Pythagorean triplet is a set of three natural numbers, a<b<c, for which,

a² + b² = c²

For example, 3² + 4² = 9 + 16 = 25 = 5².

There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.

for($a = 1; $a<500; $a++){
for($b = 500-$a; $b<500; $b++){
$c = 1000-$a-$b;
if( ($c*$c) == ($a*$a+$b*$b)){
$this->a = $a;
$this->b = $b;
$this->c = $c;
$a=500;
$b=500;
}
}
}
$a = 200
$b = 375
$c = 425
$answer = 31,875,000