logo CodeStepByStep logo

RecursionMystery1

Language/Type: VB recursion

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

Public Sub RecursionMystery1(x As Integer, y As Integer)
    If y <= 0
        Console.Write("0 ")
    ElseIf x > y
        Console.Write(x & " ")
        RecursionMystery1(x - y, y)
    Else
        RecursionMystery1(x, y - x)
        Console.Write(y & " ")
    End If
End Sub
RecursionMystery1(6, 3)
RecursionMystery1(2, 3)
RecursionMystery1(5, 8)
RecursionMystery1(21, 12)
RecursionMystery1(3, 10)

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.