Cod sursa(job #3002828)
Utilizator | Data | 15 martie 2023 11:24:58 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{int n, cont=0;
fin>>n;
int v[n+1];
v[0]=1;
v[1]=1;
for(int i=1; i<=n; i++)
v[i]=0;
for(int i=2; i*i<=n; i++)
{
if(!v[i])
for(int j=2; j<=n/i; j++)
v[i*j]=1;
}
for(int i=2; i<=n; i++)
if(!v[i])
cont++;
fout<<cont;
return 0;
}