Cod sursa(job #2643424)
Utilizator | Data | 19 august 2020 19:45:53 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
unsigned long long n,nr=0;
bool ok;
f>>n;
for(unsigned long long i=2;i<=n;++i)
{
ok=true;
for(unsigned long long j=2;j*j<=i&&ok;++j)
if(i%j==0)
ok=false;
if(ok)
++nr;
}
g<<nr;
}