Recursion

AP Computer Science A· difficulty 2/5

public static int pow(int b, int e) {
  if (e == 0) return 1;
  return b * pow(b, e - 1);
}
// call: pow(2, 5)

What does pow(2,5) return?

  • A

    10

  • B

    25

  • C

    16

  • D

    32

    check_circle

Explanation

2^5 = 32.

Want 10 more like this — adaptive to your weak spots?

Related questions