hye guys, i have this code below to determine the smallest number that is evenly divisible by all numbers from 1-10 and it works perfectly. but when i try to change the range to 1-20, things got weird. the ans should be 232792560 and when i try to change the initial $k to 999999999 for bigger scope,but i can't get the answer which i SUPPOSE can get the answer as 999999999 > 232792560. When i tried changing $k to 233333333 then only i get the answer 232792560. WHY IS THAT? help me pls
PHP Code:<?
for ($k=9999; $k >= 1 ; $k--)
{
for ($c=0,$i=1; $i <= 10 ; $i++)
{
if ($k%$i == 0)
{
$c++;
if ($c == 10)
{
echo $k."<br>";
}
}
}
}
?>



Reply With Quote


Bookmarks