#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main(){
bool isPrime = true;
cout << "Enter a number: "; int num; cin >>num;
for (int i = 2; i<num; i++){
if (num % i == 0){
isPrime = false;
break;
}
}
cout << num << " is " << (isPrime? "":"not") << " a prime number" << endl;
return 0;
}
See Also:
No comments:
Post a Comment