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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started