Cod sursa(job #1766345)
Utilizator | Data | 27 septembrie 2016 21:05:16 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.59 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n , i , j , s, nr;
int main() {
fin>> n; i = 2; j = 1;
while ( i <= n ){
while ( j <= i ){
if ( i % j == 0 ){
s = s + 1;
}
j = j + 1;
}
if ( s == 2 ){
nr = nr + 1;
}
i = i + 1;
j = 1;
s = 0;
}
fout<< nr;
return 0;
}