+ 1
How we write a prime no using while loop
prime no with all method
1 Respuesta
+ 6
You can use recursion
bool isPrime(int num, int divisor = 2);
bool isPrime(int num, int divisor){
if(num == 1){
return true;
}else{
if(num%divisor == 0){
return false;
}else{
if(divisor == num){
return false;
}
return isPrime(num, divisor++);
}
}
}