Cod sursa(job #1976727)
Utilizator | Data | 4 mai 2017 08:39:37 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#include<cmath>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
int main()
{
int n,i,j,jeep=0; bool skoda;
in>>n;
if(n>=2)
jeep++;
for(i=3;i<=n;i=i+2)
{
skoda=1;
for(j=2;j<=sqrt(i);j++)
{
if(i%j==0)
skoda=0;
}
if(skoda==1)
jeep++;
}
out<<jeep;
return 0;
}