X276: Recursion Programming Exercise: log

For function 'log', write the missing base case condition and the recursive call. This function computes the log of "n" to the base "b". As an example: log 8 to the base 2 equals 3 since 8 = 2*2*2. We can find this by dividing 8 by 2 until we reach 1, and we count the number of divisions we make. You should assume that "n" is exactly "b" to some integer power.

Examples:

log(2, 4) -> 2
log(10, 100) -> 2

Your Answer:

Reset

Feedback

Your feedback will appear here when you check your answer.