fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define MX 100000000
  4. bool prime[MX+2];
  5. int cnt=-1;
  6.  
  7. void sieve()
  8. {
  9. prime[1] = 1;
  10. for(int i = 2;i*i<=MX;i++)
  11. {
  12. if(prime[i] == 0)
  13. {
  14. for(int j = i*i;j<=MX;j+=i)
  15. {
  16. prime[j] = 1;
  17. }
  18. }
  19. }
  20. }
  21. int main()
  22. {
  23. sieve();
  24. for(int i=2;i<=10000;i++)
  25. {
  26. if(prime[i]==0)
  27. {
  28. cnt++;
  29. if(cnt%100==0)
  30. {
  31. printf("%d\n",i);
  32. }
  33.  
  34. }
  35. }
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0.96s 101312KB
stdin
Standard input is empty
stdout
2
547
1229
1993
2749
3581
4421
5281
6143
7001
7927
8837
9739