Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define max 10001
- #include <cstring>
- int a[max - 1] ;
- bool pr[max];
- using namespace std;
- void siv()
- {
- memset(pr,true,max);
- pr[0] = false;
- pr[1] = false;
- int c = 0;
- for(int i = 2; i <= (int)sqrt(max) + 1 ; i++)
- {
- if(pr[i])
- {
- a[c++] = i;
- for(int j = i * i; j <= max; j= j + i)
- {
- pr[j] = false;
- }
- }
- }
- for(int i = 2; i <= max; i++)
- {
- if(pr[i])
- printf("%d ",i);
- }
- }
- int main()
- {
- siv();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement