Problem
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
Solution
$i = 2;
for ($j = 1; $j <= 20; $j++) {
if ($i % $j > 0) {
for ($k = 1; $k <= 20; $k++) {
if (($i * $k) % $j == 0) {
$i *= $k;
break;
}
}
}
}
echo $i;