Pagini recente » Cod sursa (job #1218101) | Cod sursa (job #2215358) | Cod sursa (job #1640923) | Cod sursa (job #2108799) | Cod sursa (job #248094)
Cod sursa(job #248094)
#include <iostream.h>
#include <math.h>
#include <fstream.h>
fstream f("ciur.in",ios::in);
fstream g("ciur.out",ios::out);
int main ()
{
long i,n,d,ok,k;
f>>n;
k=0;
for (i=1;i<=n;i++) {
ok=1;
if (i!=2 && i%2==0) ok=0;
else {
d=3;
while (d<=sqrt(n) && ok==1) {
if (i%d==0) ok=0;
else {
d=d+2;
}
}
}
if (ok==1) k++;
}
g>>k;
return 0;
}