← all problems

Fix sumOddsUpTo 🌶️

The method below is supposed to return the sum of the odd numbers from 1 up to and including n, so sumOddsUpTo(9) is 1 + 3 + 5 + 7 + 9, which is 25. It leaves out the last odd number when n itself is odd. Find the bug and fix it. Run the tests and read each result: a wrong value, an exception and a loop that never ends are different clues.