Claus Witt

software and web developer

Archive for the ‘evenly divisable’ tag

Project Euler Problem Five

without comments

Continuing our combined node.js and project euler posts. We got to problem five, which asks us “What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?”.

First of all we only check numbers below or equal to 20! because we know for sure that this number will satisfy the criterium of the question, we just don’t know if there is a result below this number, we also know that the number must be at least 20. For this reason we check all numbers between 20 and 20! if all numbers between 1 and 20 is a divisor – if one of the numbers fail, we move on to the next candidate. As soon as a candidate proves to be correct, we exit and return the result.

Written by Claus Witt

June 7th, 2010 at 7:30 am