Advertisement
a53

Ciurul Lui Eratosthenes

a53
Nov 11th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. #include <iostream>
  2. #define NN 1000001
  3. using namespace std;
  4. int n,v[NN];
  5.  
  6. int main()
  7. {
  8. cin>>n;
  9. v[0]=v[1]=1;
  10. for(int i=2;i*i<=n;++i)
  11. if(v[i]==0)
  12. for(int j=2;i*j<=n;++j)
  13. v[i*j]=1;
  14. for(int i=1;i<=n;++i)
  15. if(v[i]==0)
  16. cout<<i<<' ';
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement