Created
November 8, 2014 22:08
-
-
Save kiloreux/710b04d9bda285e1f193 to your computer and use it in GitHub Desktop.
My solution to Project Euler problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<cmath> | |
using namespace std; | |
bool isPrime(long long var) | |
{ | |
for(int i=2;i<=sqrt(var);i++) | |
{ | |
if(var%i==0) | |
{ | |
return false ; | |
} | |
} | |
return true; | |
} | |
int main(void) | |
{ | |
long long sum=0; | |
for(int i=2;i<2000000;i++) | |
{ | |
if(isPrime(i)) | |
{ | |
sum+=i; | |
} | |
} | |
cout<<sum<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment