Pagini recente » Cod sursa (job #494965) | Rating Oltean Patricia (patriciaoltean) | Cod sursa (job #181324) | Cod sursa (job #450096) | Cod sursa (job #2723779)
#include <bits/stdc++.h>
using namespace std;
bool c[1000005];
int main()
{
ifstream fin("eratostene.in");
ofstream fout("eratostene.out");
c[0] = c[1] = 1;
for(int i = 2; i <= 1000; ++i)
if(c[i] == 0)
for(int j = 2; i * j <= 1000000; ++j)
c[i * j] = 1;
int n;
fin >> n;
int x;
int cnt = 0;
for(int i = 1; i <= n; ++i){
if(c[i] == 0)
cnt++;
}
fout << cnt;
return 0;
}