Project Euler : Problem 010

Project Euler problems in Oforth . Feel free to post your own code.

Project Euler : Problem 010

Postby Franck » 30 Jul 2015 17:10

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.

Find the sum of all the primes below two million.

Code: Select all
// Using method #isPrime declared into Problem 007.

: pe010(n)    // ( n -- n ) : Return sum of all primes below n
{
| i |
   2 3 n for: i [ i isPrime ifTrue: [ i + ] ]
}
Franck
 
Posts: 155
Joined: 29 Oct 2014 19:01

Return to Project Euler in Oforth

Who is online

Users browsing this forum: No registered users and 1 guest

cron