Respuesta :
Answer:
int is-prime-number(int P){
if (Q == 1) {
return 1;
} else{
if (P%Q == 0){
return 0;
} else {
Q = Q - 1;
is-prime-number(P);
}
}
}
Explanation:
- I have defined a simple function by the name of is-prime-number which takes an integer input the number to be tested whether it is prime or not and returns an integer output.
- if the function returns 1 (which means true) this means that the number is prime otherwise the number is not prime.
- Now we just need to call this function in our main function and print "Number is prime" if function returns one otherwise print "Number is not prime".
- Another important point to note here is that we need to define Q as Global variable since we are not passing it as a input to the function but we are using it inside the function so it needs to be declared as a Global variable.