Cod sursa(job #2695530)
| Utilizator | Data | 13 ianuarie 2021 16:11:53 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <bits/stdc++.h>
using namespace std;
bool c[1000005];
int main()
{
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;
int cnt=0;
cin >> n;
for(int i = 1; i <= n; ++i)
{
if(c[i] == 0)
cnt++;
}
cout << cnt;
return 0;
}
