← Unit 2 · all exercises
Saved in this browser only

First power of two past a limit

Starting at 1, keep doubling until the value is greater than the limit, then return it. For a limit of 10 that is 16.

int firstPowerOver(int limit)

Solution.java
Loading editor…
Results

Examples

  • firstPowerOver(10) → 16
  • firstPowerOver(100) → 128

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