Bending Spoons Task
#include <iostream> bool isPrime(int number) { if (number == 0 or number == 1) { return false; } for (int i = 2; i * i <= number; i++) { if (number % i != 0) { return false; } } return true; } int main() { int number; std::cout << "Enter a positive number: " << std:: endl; std::cin >> number; std::cout << "The entered number is " << (isPrime(number) ? "" : "not ") << "prime" << std::endl; return 0; }
Leave a Comment