Re: Math problem (222)

From: Date: Wed, 02 Oct 2002 18:19:29 +0000
Subject: Re: Math problem (222)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-118629@lists.php.net to get a copy of this message
> 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

« previous php.general (#118629) next »