Quick Quiz on Recursion with Numbers!

This lesson will test your knowledge on recursion with numbers.

1

What is the output of the following code?

public static int pow(int b, int p)
{
    if (p == 0)
    {
       return 1;
    }
    else
    {
         return (b*pow(b, p-1));
    }
}

public static void main(String args[])
{
			System.out.print(pow(2,5));
}
A)

2

B)

16

C)

32

D)

1

Question 1 of 30 attempted

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.