]> gitweb.factorcode.org Git - factor.git/blob - extra/project-euler/005/005.factor
633edbdcb56406d2df485cd852e1890ced2b21c2
[factor.git] / extra / project-euler / 005 / 005.factor
1 ! Copyright (c) 2007, 2009 Aaron Schaefer.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: math math.functions math.ranges project-euler.common sequences ;
4 IN: project-euler.005
5
6 ! http://projecteuler.net/index.php?section=problems&id=5
7
8 ! DESCRIPTION
9 ! -----------
10
11 ! 2520 is the smallest number that can be divided by each of the numbers from 1
12 ! to 10 without any remainder.
13
14 ! What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?
15
16
17 ! SOLUTION
18 ! --------
19
20 : euler005 ( -- answer )
21     20 [1..b] 1 [ lcm ] reduce ;
22
23 ! [ euler005 ] 100 ave-time
24 ! 0 ms ave run time - 0.14 SD (100 trials)
25
26 SOLUTION: euler005