graph LR
accTitle: Iterative sum of even numbers
accDescr: Starting at one, the algorithm adds even values to the sum, skips odd values, and stops after the supplied number.
A((Start)) --> B[/number/]
B --> C[Set sum to 0]
C --> D[Set i to 1]
D --> E{"Is i<br>less than or<br>equal to<br>number?"}
E -- Yes --> F{"Is i<br>an even<br>number?"}
F -- Yes --> G[Add i<br>to the sum]
F -- No --> H[Keep sum the same]
G --> I[Increase i by one]
E -- No --> J[/sum/]
H --> I
I --> E
J --> K((End))
Iterative sum algorithm
Figure 1 represents the iterative sum and shows which values change the accumulator. What will be the output if the input—labeled number—is 4?
Choose the correct output:
- 4
- 6
- 8
- 10
- 12