Cod sursa(job #185461)
Utilizator | Data | 25 aprilie 2008 13:51:02 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include<fstream.h>
#include<math.h>
int n,np;
int main()
{
ifstream input("ciur.in");
ofstream output("ciur.out");
input>>n;
int k,x,ok;
for (k=2;k<=n;k++)
{
ok=1;
for(x=2;x<=sqrt(k);x++)
{
if (k%x==0)
ok=0;
}
if(ok==1)
np++;
}
output<<np;
return 0;
}