Cod sursa(job #280366)
Utilizator | Data | 13 martie 2009 12:40:36 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream.h>
int main ()
{
long n,k=0,i,x,d;
ifstream f("ciur.in");
ofstream g("ciur.out");
f>>n;
for(i=2;i<=n;i=i++)
{
x=i;
if(x>=2)
{
d=2;
while(d<=x/2&&x%d!=0)
d++;
if(d>x/2)
k++;
}
}
g<<k;
f.close();
g.close();
return 0;
}