Cod sursa(job #1342782)
Utilizator | Data | 14 februarie 2015 15:31:35 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include <fstream>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
int main()
{
int n,i,j,prim,cnt=0;
in>>n;
for(i=2;i<=n;i++){
prim=1;
for(j=2;j<=i/2;j++){
if(i%j==0){
prim=0;
}
}
if(prim==1){
cnt++;
}
}
out<<cnt;
}