Cod sursa(job #916117)

Utilizator ionutpPala Ionut ionutp Data 15 martie 2013 20:29:12
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.63 kb
#include <fstream>
using namespace std;

ifstream fin("date.in");
ofstream fout("date.out");

bool Prime[10000];
int n, count;
void Read();
void Erathostenes();
int main()
{

    Read();
    Erathostenes();
    fin.close();
    fout.close();
    return 0;
}
void Read()
{
    fin >> n;
}
void Erathostenes()
{
    for( int i = 2; i <= n; i++ )
    {
         Prime[i] = true;
    }
    for( int i = 2; i <= n; i++ )
    {
        if(Prime[i] == true)
        {
            count++;
            for( int j = 2 * i; j <= n; j += i )
            Prime[j] = false;

        }
    }
    fout << count;
}