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.
|
2009-03-19 00:05:32 -04:00
|
|
|
USING: math.primes sequences project-euler.common ;
|
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.
|
|
|
|
|
2008-11-05 01:11:15 -05:00
|
|
|
! Find the sum of all the primes below two million.
|
2007-12-18 20:57:16 -05:00
|
|
|
|
|
|
|
|
|
|
|
! SOLUTION
|
|
|
|
! --------
|
|
|
|
|
|
|
|
: euler010 ( -- answer )
|
2008-11-05 01:11:15 -05:00
|
|
|
2000000 primes-upto sum ;
|
2007-12-18 20:57:16 -05:00
|
|
|
|
2008-12-26 14:58:46 -05:00
|
|
|
! [ euler010 ] 100 ave-time
|
|
|
|
! 15 ms ave run time - 0.41 SD (100 trials)
|
2007-12-18 20:57:16 -05:00
|
|
|
|
2009-03-19 00:05:32 -04:00
|
|
|
SOLUTION: euler010
|