+ 1

How we write a prime no using while loop

prime no with all method

21st Oct 2017, 10:13 AM
Usama Riaz
Usama Riaz - avatar
1 Resposta
+ 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++); } } }
21st Oct 2017, 10:29 AM
Dapper Mink
Dapper Mink - avatar