Skip to content

Instantly share code, notes, and snippets.

@chimericdream
Created November 24, 2016 05:17
Show Gist options
  • Select an option

  • Save chimericdream/1283f07278b27fff3975567d5a4c74e7 to your computer and use it in GitHub Desktop.

Select an option

Save chimericdream/1283f07278b27fff3975567d5a4c74e7 to your computer and use it in GitHub Desktop.
Project Euler - Problem #5
$exitLoop = false;
$x = 2520;
while (!$exitLoop) {
if ($x % 20 || // 20 gives us 1, 2, 4, 5, 10 as well
$x % 19 || // 19 is prime
$x % 18 || // 18 gives us 3, 6, 9 as well
$x % 17 || // 17 is prime
$x % 16 || // 16 gives us 2, 4, 8 as well
$x % 15 || // 15 gives us 3, 5 as well
$x % 14 || // 14 gives us 2, 7 as well
$x % 13 || $x % 12 || $x % 11) {
$x += 2520;
} else {
$exitLoop = true;
}
}
echo $x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment