Cod sursa(job #1529213)
Utilizator | Data | 20 noiembrie 2015 16:59:14 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
#include <cmath>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
int main()
{
int n,i,j,gxg=0,best=0;
in>>n;
for(i=2;i<=n;i++)
{
gxg=0;
for(j=2;j<=sqrt(i);j++)
{
if(i%j==0)
gxg++;
}
if(gxg==0)
best++;
}
out<<best;
return 0;
}