Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int a[10000009];
- void sieve(){
- for(int i=0;i<10000009;i++){
- a[i]=1;
- }
- a[0]=a[1]=0;
- for(int i=2;i*i<10000009;i++){
- for(int j=i*i;j<10000009;j+=i){
- a[j]=0;
- }
- }
- }
- int main() {
- /* Enter your code here. Read input from STDIN. Print output to STDOUT */
- unsigned int n;
- cin>>n;
- sieve();
- for(int i=0;i<=n;i++){
- if(a[i]==1){
- cout<<i<<" ";
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment