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.
|
2008-01-06 21:18:59 -05:00
|
|
|
USING: 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.
|
|
|
|
|
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-11-05 01:11:15 -05:00
|
|
|
! [ euler010 ] time
|
|
|
|
! 266425 ms run / 10001 ms GC time
|
|
|
|
|
|
|
|
! TODO: this takes well over one minute now that they changed the problem to
|
|
|
|
! two million instead of one. the primes vocab could use some improvements
|
2007-12-18 20:57:16 -05:00
|
|
|
|
|
|
|
MAIN: euler010
|