Cod sursa(job #1342775)
Utilizator | Data | 14 februarie 2015 15:25:08 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 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=3;i<=n;i++){
prim=1;
for(j=2;j<i/2;j++){
if(i%j==0){
prim=0;
}
}
if(prim==1){
cnt++;
}
}
if(n==2){
cnt++;
}
out<<cnt;
}