Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Project Euler("https://projecteuler.net/archives")
- Problem 10
- The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
- Find the sum of all the primes below two million.
- */
- int main(){
- long long sum = 0;
- int size = 2000000;
- bool prime = true;
- for(int i = 2; i < size; i++){
- for(int j = 2; j < i; j++){
- if( i%j == 0){
- prime = false;
- break;
- }
- }
- if(prime == true){
- sum += i;
- }
- if(prime == true) cout << i << " " << sum << endl;;
- prime = true;
- }
- system("PAUSE");
- }
Advertisement
Add Comment
Please, Sign In to add comment