Cod sursa(job #2829101)
Utilizator | Data | 8 ianuarie 2022 12:04:16 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <bits/stdc++.h>
using namespace std;
int steve[1000005];
int main(){
steve[0] = 1; steve[1] = 1;
int n;
cin>>n;
for (int i=2;i<=n;++i){
if (!steve[i]){
for (int x=2*i;x<=n;x+=i)
steve[x] = 1;
cout<<i<<" ";
}
}
}