Cod sursa(job #2658325)
Utilizator | Data | 13 octombrie 2020 18:19:26 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int nr,n,i,ok;
int main()
{
f >> n;
for(i=1;i<=n;i++)
{
ok = 1;
for(int j=2;j<=i/2;j++)
if(i%j==0)
ok = 0;
if(ok==1)
nr++;
}
g << nr;
return 0;
}