Cod sursa(job #2093449)
Utilizator | Data | 23 decembrie 2017 18:25:36 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int main()
{ int n,i,d,k=0;
f>>n;
for(i=2;i<=n;i++)
{ int pp=1;
for(d=2;d<=i/2;d++)
{
if(i%d==0){pp=0;break;}
}
if(pp==1)k++;
} g<<k;
}