ProjectEuler.net
 |   |   |   |   |   |   |   |   |   | 

Project Euler.net Answers

Problem 5

Solved on 2/29/2008

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 number that is evenly divisible by all of the numbers from 1 to 20?

$answer = 6;
$factor = array();
for ($i = 5; $i <= 20; $i++){
  if(isPrime($i)) $answer = $answer*$i;
}
$answer = $answer * 2 * 2 * 2 * 3; // this will take care of the multiple factors
answer = 232,792,560