5.11 · exercise
The overeager counter
warning
This program is broken. Find the bug and fix it so the checks pass.
This countdown should print n down to 1, one number per line, and stop. Run it with the 5 in the stdin box and look closely at the output: it goes one line too far.
The loop's exit test is the culprit. Fix the condition so the countdown ends where it should, and leave everything else alone.
What is checked
- exactly five lines,
5down to1 - the program exits cleanly
- the countdown still comes from the loop
- the same holds for other starting values you do not see; a start of 0 or below prints nothing at all
specification
stdin5
stdoutprints the right output
exitexits with the right code
sourceuses
subhiddenright output and exit code on 4 more inputs you do not see
We run your program on the input above and on the hidden ones, and compare what it does. Nothing is matched against a stored solution.