Question: Please use Python 3 to solve this problem. Write a recursive function to convert any decimal number into any base from 2 to 9. See

Please use Python 3 to solve this problem.

Write a recursive function to convert any decimal number into any base from 2 to 9. See the template and I/O examples below for details. If your function isn't recursive, then you will not get credit.

Your function should only be about a half-dozen lines and there must not be any loops anywhere in your code.

One part of the problem is to figure out what the base case is.

Also note that the answer is printed to the screen, not returned as a value.

given code

def main():

n = int(input())

b = int(input())

print(n, "in base", b, "is ", end="")

toBase(n, b)

if __name__ == "__main__":

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!