logo CodeStepByStep logo

recursion_mystery_print_digits

Language/Type: Python recursion

For each call to the following recursive function, write the output that would be produced, as it would appear on the console.

def recursion_mystery_print_digits(x):
    if x < 10:
        print(x, end="")
    else:
        y = x % 10
        print(y, end="")
        recursion_mystery_print_digits(x // 10)
        print(y, end="")
recursion_mystery_print_digits(7)
recursion_mystery_print_digits(38)
recursion_mystery_print_digits(194)
recursion_mystery_print_digits(782)
recursion_mystery_print_digits(3842)

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.