Cod sursa(job #1184319)
Utilizator | Data | 12 mai 2014 10:02:53 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int main()
{long int n,i,k=0,j,nrd;
f>>n;
for(i=2;i<=n;i++)
{nrd=1;
for(j=1;j<=i/2;j++)
if(i%j==0)
nrd++;
if(nrd==2)
k++;
}
g<<k;
return 0;
}