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 + ] ]

}

1 post
• Page **1** of **1**

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

Find the sum of all the primes below two million.

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:**162**Joined:**29 Oct 2014 19:01

1 post
• Page **1** of **1**

Return to Project Euler in Oforth

Users browsing this forum: No registered users and 1 guest