5.1 · 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 expected output
exitexits with the expected code
sourcecomputes the result (does not hardcode it)
Checked by running your program against expected behavior, never by matching a stored solution.
loading editor...