Programming a recursive function: determining if the given number is prime.

Report a typo

Write a recursive function which would return true if the given number is prime and false if it is not.

Hint: a second parameter is used to indicate which number the function is currently assuming to be the divisor.

Sample Input 1:

3

Sample Output 1:

true
Write a program in Kotlin
fun isPrime(n: Int, i: Int = 2): Boolean {
// a few base cases here
// recursive case here
}

fun main() {
val n = readLine()!!.toInt()
print(isPrime(n))
}
___

Create a free account to access the full topic