Skip to content

Instantly share code, notes, and snippets.

@shohan4556
Created October 4, 2014 15:22
Show Gist options
  • Save shohan4556/712cf9ca8108f3cd34de to your computer and use it in GitHub Desktop.
Save shohan4556/712cf9ca8108f3cd34de to your computer and use it in GitHub Desktop.
#include <stdio.h>
main()
{
long long int i,j,k,n=2000000,sum=2;
int count;
for(i=3;i<n;i++){
count=1; // assume that it is prime
for(j=2;j<=sqrt(i);j++){
if(i%j==0){
count=0; // it is not prime
break;
} // end control flow
} // end child loop
if(count==1)
sum=sum+i;
} // end parent loop
printf("%lld\n",sum);
} // end main loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment