Practice · 4 of 4
Diagnose a trace bug
CHALLENGE
Difficulty: intermediate+25 XP
This method should return 1 + 2 + ... + n for n >= 1 (and 0 for n <= 0), but its loop never terminates correctly for some inputs. Trace sumTo(3) and sumTo(-1) with a state table, find the drift, and fix it.
Press Submit to check your solution.
Back to lesson: Practice: Tracing lab