Flowchart: sum from 1 to n with a loop
Read an integer n, add i to a running total while i goes from 1 to n, then print the total.
Steps
- Start, then read an integer n.
- Set the total to 0 and i to 1.
- Decide whether i is at most n.
- If it is, add i to the total, raise i by 1 and go back to the decision.
- When i passes n, print the total and end.
Good to know
- The line that goes back is the loop. Without the arrow back to the decision, the chart runs only once.
- If n is less than 1, nothing is added and the chart prints 0.
Drawing happens in this browser only. Your text is never sent to a server. Symbol rules differ a little between textbooks, so check them against your course before you hand in.