Pagini recente » Cod sursa (job #2521507) | Cod sursa (job #1127149) | Cod sursa (job #3273152) | Cod sursa (job #1319042) | 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;
}