Double for loop not working
<p>Im trying to solve Euler's Project 9 using PHP. Im pretty sure my logic is fine, but my double for-loop only goes through the first loop, completes the second loop and stops. Any1 knows what Im doing wrong? I want to do the first one 998 times and the second one 998 times. ( NB: I know that I can optimize the code because I $ will never be higher then 331 due to a

<pre><code>//
//A Pythagorean triplet is a set of three natural numbers, a &lt; b &lt; 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.

$na = array();
$a=1;
$b=1;
$c=0;
$z=998;//upper bound
for($a;$a&lt;$z;$a++){
    for($b;$b&lt;$z;$b++){
        $c=(1000-$a)-$b;
        if(($a*$a)+($b*$b)==($c*$c))
            echo "played: $a + $b + $c = 1000&lt;br /&gt;";
    }
}
</code></pre>

<p>Result is (When I comment the if out) :
played: 1 + 1 + 998 = 1000
 to
played: 1 + 997 + 2 = 1000</p>
