Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- int list[2000000] = {2,3}, size=2, n=3, sqrt_n, i;
- long long int acc = 5LL;
- while (1)
- {
- do
- {
- n += 2;
- sqrt_n = sqrt(n);
- for (i=0; i<size && list[i] <= sqrt_n; i++)
- {
- if (n % list[i] == 0) break;
- }
- } while (list[i] <= sqrt_n);
- if (n >= 2000000) break;
- acc += (list[size++] = n);
- }
- printf("sum = %lld\n",acc);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement