Cod sursa(job #795314)

Utilizator skyper96skyper skyper96 Data 8 octombrie 2012 11:51:27
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.4 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    ifstream f("ciur.in");
    ofstream g("ciur.out");
    int n,nr,nd,i,j;
    f >> n;
    nr=0;
    for(i=2;i<=n;i++)
    {
        nd=0;
        for(j=2;j<=i/2;j++)
        {
            if(i%j==0)
                nd++;
        }
        if (nd==0)
            nr++;
    }
    g << nr;
    return 0;
}