Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a recursive python function int_log_base(base, number) that does the follo

ID: 3763709 • Letter: W

Question

Write a recursive python function int_log_base(base, number) that does the following:

The integer log base x of y is the number of times you must divide y by x to get a number between 1 (inclusive) and x (exclusive).For example, int_log_base(3, 1112) is 6 because 1112 / 3 / 3 / 3 / 3 / 3 / 3 (which has 6 divisions in it) is 1.525... which is between 1 and 3. You may assume the base and number will both be strictly greater than 1. Do not use the ** operator or any math library functions in your solution; do it recursively instead.

Can't use a loop

Explanation / Answer

#! /usr/bin/Python
def int_log_base(base, number):
quotient = number/base;
if (quotient >= 1 and quotient < base):
return 1;
return 1+int_log_base(base, quotient)

print int_log_base(3,1112);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote