> What is wrong with it? Any help at all is greatly apreciated.

Consider the differences between my code below and yours. And as far as I
can see, there's no combination higher than eleven, lower than 987 which
doesn't work out.

<?
for ($i = 12; $i < 987; $i++) {

    $newI = $i;

    settype($newI, "string");

    $newI = str_pad($newI, 3, "0", STR_PAD_LEFT);

    $digits = $newI[0] + $newI[1] + $newI[2];

    $num1 = $newI[0].$newI[1].$newI[2];
    $num2 = $newI[0].$newI[2].$newI[1];
    $num3 = $newI[1].$newI[0].$newI[2];
    $num4 = $newI[1].$newI[2].$newI[0];
    $num5 = $newI[2].$newI[0].$newI[1];
    $num6 = $newI[2].$newI[1].$newI[0];

    $sum = $num1 + $num2 + $num3 + $num4 + $num5 + $num6;

    $answer = $sum / $digits;

    if ($answer != "222") {
        echo $i." does not fit in the scheme.";
    }

}
?>

   Jome



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to