Pagini recente » Cod sursa (job #152774) | Cod sursa (job #2702087) | Cod sursa (job #1229389) | Cod sursa (job #3215621) | Cod sursa (job #3236856)
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
const int nmax = 2e6+10;
vector<short int> eratostene(nmax,0);
int n;
int main(){
fin >> n;
int ans = 0;
eratostene[1] = eratostene[0] = 1;
for(int i = 2; i <=n; i++){
if(!eratostene[i]){
ans++;
for(int j = i*2; j <=n; j += i){
eratostene[j] = 1;
}
}
};
fout << ans;
return 0;
}