Cod sursa(job #270131)
Utilizator | Data | 3 martie 2009 19:26:56 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include<fstream.h>
int main ()
{ int x,n,i,ok=1,k=1;
ifstream f("ciur.in");
ofstream g("ciur.out");
f>>n;
for (i=3; i<=n; i+=2)
{ ok=1;
for (x=3;x*x<=i;x+=2)
if (i%x==0) { ok=0; break; }
if (ok==1) k++;
}
g<<k;
return 0;
}