Cod sursa(job #1010600)
| Utilizator | Data | 15 octombrie 2013 12:37:33 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <fstream>
#include <math.h>
using namespace std;
int verifica(long x){
long j=0;
long ok=0;
if(x%2==0)
return 0;
else{
for(j=3;j<=sqrt(x);j++)
if(x%j==0)
ok=1;
if(ok==0)
return 1;
else return 0;
}
}
int main()
{
long long n,i;
ifstream f("ciur.in");
ofstream g("ciur.out");
f>>n;
long cont=2;
for(i=4;i<=n;i++){
cont=cont+verifica(i);
}
g<<cont;
return 0;
}
