Alice knows that if a number
n
has no divisor less than or equal to
\(\sqrt n\), then the number
n
is a prime number and its minimum prime divisor is the number itself
n
. You have been asked to write a program that will find the minimum prime divisor of any number.
Make your decision using functions. Write the following functions:
- the
isPrime(n)
function, which will take an integer and return True if the number is prime and False if it is not prime.
-
minDivisor(n)
function, which will return the minimum simple divisor.
The main program must contain a number input, a
minDivisor(n)
function call, and a response output.
Input
The program receives as input a natural number
n
> 1.
Imprint
Print the answer to the problem.
Examples
# |
Input |
Output |
1 |
4 |
2 |
2 |
5 |
5 |