logo CodeStepByStep logo

Mystery1

Language/Type: VB recursion recursive tracing

For each call to the following subroutine, indicate what console output is produced:

Public Sub Mystery1(k As Integer)
    If k <= 1
        Console.Write(k)
    Else
        Mystery1(k \ 2)
        Console.Write(" = " & k)
    End If
End Sub
Mystery1(1)
Mystery1(4)
Mystery1(16)
Mystery1(30)
Mystery1(100)

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.