2007-12-21 07:05:45 -05:00
|
|
|
! Copyright (c) 2007 Aaron Schaefer, Samuel Tardieu.
|
2007-12-18 20:57:16 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2007-12-30 22:41:04 -05:00
|
|
|
USING: kernel math.primes sequences ;
|
2007-12-18 20:57:16 -05:00
|
|
|
IN: project-euler.010
|
|
|
|
|
|
|
|
! http://projecteuler.net/index.php?section=problems&id=10
|
|
|
|
|
|
|
|
! DESCRIPTION
|
|
|
|
! -----------
|
|
|
|
|
|
|
|
! The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
|
|
|
|
|
|
|
|
! Find the sum of all the primes below one million.
|
|
|
|
|
|
|
|
|
|
|
|
! SOLUTION
|
|
|
|
! --------
|
|
|
|
|
|
|
|
: euler010 ( -- answer )
|
2007-12-30 22:41:04 -05:00
|
|
|
1000000 primes-upto sum ;
|
2007-12-18 20:57:16 -05:00
|
|
|
|
2007-12-26 22:04:39 -05:00
|
|
|
! [ euler010 ] 100 ave-time
|
|
|
|
! 14 ms run / 0 ms GC ave time - 100 trials
|
2007-12-18 20:57:16 -05:00
|
|
|
|
|
|
|
MAIN: euler010
|