logo CodeStepByStep logo

RecursionMystery3

Language/Type: VB recursion

For each of the calls to the following recursive function below, indicate what output is produced:

Public Function RecursionMystery3(n As Integer)
    If n < 0
        Return -RecursionMystery3(-n)
    ElseIf n < 10
        Return (n + 1) Mod 10
    Else
        Return 100 * RecursionMystery3(n \ 10) + (n + 1) Mod 10
    End If
End Function
RecursionMystery3(7)
RecursionMystery3(42)
RecursionMystery3(385)
RecursionMystery3(-790)
RecursionMystery3(89294)

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.