#include
long int primenumbers[15000];
long int i, x, z;
long int j = 0;
long int k = 0;
long int l = 0;
long long int sum = 0;
int main()
{
for(x = 2; x < 100000; x++) // Ideally this would be (x = 2; x < 2000000; x++), but it's okay to do the loop in pieces
{
for(i = 2; i < x && j < 1; i++) // This j < 1 is included to terminate the loop as soon as x is found not to be prime
{
if(x % i == 0)
{
j++;
}
}
if(j == 0)
{
primenumbers[k] = x; // Store x in memory if it's found to be prime
k++;
}
j = 0;
}
// Now that all prime numbers are known, add them together
for(l = 0; l < k; l++)
sum = sum + primenumbers[l];
// Display the result on the screen
printf("\n%lli is the sum of prime numbers.", sum);
return 0;
}