Skip to content

Instantly share code, notes, and snippets.

@kiloreux
Created November 8, 2014 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiloreux/710b04d9bda285e1f193 to your computer and use it in GitHub Desktop.
Save kiloreux/710b04d9bda285e1f193 to your computer and use it in GitHub Desktop.
My solution to Project Euler problem
#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