2009-05-01 20:46:25 -04:00
|
|
|
! Copyright (c) 2007, 2009 Aaron Schaefer.
|
2007-12-18 20:57:16 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-05-01 20:46:25 -04:00
|
|
|
USING: math math.functions math.ranges project-euler.common sequences ;
|
2007-12-18 20:57:16 -05:00
|
|
|
IN: project-euler.005
|
|
|
|
|
|
|
|
! http://projecteuler.net/index.php?section=problems&id=5
|
|
|
|
|
|
|
|
! DESCRIPTION
|
|
|
|
! -----------
|
|
|
|
|
|
|
|
! 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?
|
|
|
|
|
|
|
|
|
|
|
|
! SOLUTION
|
|
|
|
! --------
|
|
|
|
|
|
|
|
: euler005 ( -- answer )
|
2009-05-01 20:46:25 -04:00
|
|
|
20 [1,b] 1 [ lcm ] reduce ;
|
2007-12-18 20:57:16 -05:00
|
|
|
|
|
|
|
! [ euler005 ] 100 ave-time
|
2008-11-04 01:04:03 -05:00
|
|
|
! 0 ms ave run time - 0.14 SD (100 trials)
|
2007-12-18 20:57:16 -05:00
|
|
|
|
2009-03-19 00:05:32 -04:00
|
|
|
SOLUTION: euler005
|