Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool isPrime(int number) {
- for (int i = 2; i < number; i++) {
- int num = number % i;
- if (num == 0) {
- return false;
- }
- }
- return true;
- }
- int main() {
- int userInput;
- cout << "ENTER NUMBER";
- cin >> userInput;
- if (isPrime(userInput)) {
- cout << "Prime";
- }
- else {
- cout << "Not Prime";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement