Cod sursa(job #1772048)
Utilizator | Data | 6 octombrie 2016 14:33:20 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include<iostream>
using namespace std;
bool Prim(int x){
if (x <= 1)
return false;
if (x == 2)
return true;
for (int i = 3; i * i <= x; i += 2)
if (x % i == 0)
return false;
return true;
}
int main(){
int x;
cin >> x;
if (Prim(x))
cout << x << " este prim\n";
else
cout << x << " NU este prim\n";
system("pause");
return 0;
}