← Unit 2 · all exercises
Saved in this browser only

Add up a range

Return the sum of every whole number from low up to and including high. If low is above high, return 0.

int sumBetween(int low, int high)

Solution.java
Loading editor…
Results

Examples

  • sumBetween(1, 5) → 15
  • sumBetween(3, 3) → 3

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