Cod sursa(job #2373561)
Utilizator | Data | 7 martie 2019 14:12:10 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.53 kb |
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
int n, a = 0, ok = 0;
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
ok = 1;
for(int j = 2; j < n/2; j++)
{
if(i % j == 0)
{
ok = 0;
}
if(ok == 1)
{
a++;
break;
}
}
}
printf("%d", a - 1);
}