Cod sursa(job #2247617)
Utilizator | Data | 28 septembrie 2018 20:48:01 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <fstream>
#include <math.h>
using namespace std;
int main()
{
ifstream ci ("ciur.in");
ofstream co ("ciur.out");
int n,h=1,q,ok=0;
ci >> n;
for (int i=3; i<=n; i++)
{
q=sqrt(i);
for (int j=2; j<=q; j++)
{
if (i%j==0)
{
ok=1;
break;
}
}
if (ok==0)
h++;
ok=0;
}
co << h << endl;
return 0;
}