Recursive program for prime number | Returns true if n is prime , else return false . i is current divisor to check . ; Base cases ; Check for next divisor ; Driver code
function isPrime ( n , i ) { if ( n <= 2 ) return ( n == 2 ) ? true : false ; if ( n % i == 0 ) return false ; if ( i * i > n ) return true ; return isPrime ( n , i + 1 ) ; } let n = 15 ; if ( isPrime ( n , 2 ) ) document . write ( " " ) ; else document . write ( " " ) ;