Not the most challenging one, but still:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
My Solution
#include <stdio.h>
#include <math.h>
int isPrime(num){
int i;
if (num==2)
return 1;
for (i=2;i<sqrt(num)+1;i++){
if (num%i==0)
return 0;
}
return 1;
}
int main(){
int i;
double soma=0;
for (i=2;i<2000000;i++){
if (isPrime(i)==1)
soma=soma+i;
}
printf("%lfn",soma);
return 0;
}