Cod sursa(job #900112)

Utilizator Mitsa3Neamt Mihai Mitsa3 Data 28 februarie 2013 17:44:30
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>
using namespace std;


int main()
{
    ifstream fin("ciur.in");
    ofstream fout("ciur.out");

    int n,i,d,z=0,ok;
    fin >> n;
    for(i=2;i<=n;i++)
    {
        ok=1;
        for(d=2;d<=i/2;d++)
            if(i%d==0)
                {ok=0;
                d=i/2;}
        if(ok==1)
            z++;
    }

    fout << z << "\n";

    fin.close();
    fout.close();
    return 0;
}