← Unit 1 · all exercises
Saved in this browser only

Raise to a power

Return the base raised to the given power, as a whole number. Math.pow always hands back a double, so a cast is needed.

int power(int base, int exponent)

Solution.java
Loading editor…
Results

Examples

  • power(2, 3) → 8
  • power(5, 2) → 25

There are also 3 hidden tests you can't see. Solve the problem, not the examples.