Cod sursa(job #1776656)
Utilizator | Alex S Hill shantih1 | Data | 11 octombrie 2016 18:21:00 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n , i , j , s, nr , k ;
int main() {
fin >> n ;
for ( i = 2 ; i <= n ; i ++ ){
k = 1 ;
for ( j = 2 ; j <= i - 1 ; j ++ ){
if ( i % j == 0 ){
k = 0 ;
}
}
if ( k == 1 ){
nr = nr + 1 ;
}
}
fout << nr << endl ;
}