5.6 · exercise
Sum from one to n
Write a loop that adds up every integer from 1 to n and prints the total.
The starter sets n to 10 and leaves a running total and a counter ready in registers. Fill in the loop body so it adds each value from 1 through n into the total. The program already prints whatever the total register holds.
what is checked
- the total is printed on its own line
- the program exits cleanly
- the total is built up in the loop, not written in as a constant
Specification
args
stdoutprints the right output
exitexits with the right code
sourcecomputes the result (does not hardcode it)
Checked by running your program against expected behavior, never by matching a stored solution.