Cod sursa(job #1071929)
Utilizator | Data | 3 ianuarie 2014 18:08:24 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#include<cmath>
using namespace std;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
int n,i,ok,j,p=0;
f>>n;
for(i=2;i<=n;i++)
{
ok=1;
for(j=2;j<=sqrt(i);j++)
{
if(i%j==0)
ok=0;
}
if(ok==1)
p++;
}
g<<p;
return 0;
}