graph TD
accTitle: Algorithm X
accDescr: If number is at most 1, the flowchart returns number. Otherwise a starts at 0, b at 1, and i at 2. While i is at most number, sum becomes a + b, a becomes b, b becomes sum, and i increases by 1. Then b is output.
A((Start)) --> B[/number/]
B --> C{"Is number<br>less than or<br>equal to 1?"}
C -- Yes --> D[/Return number/]
C -- No --> E[Initialize<br>a to 0]
E --> F[Initialize<br>b to 1]
F --> S[Initialize<br>sum to 0]
S --> G[Set i to 2]
G --> H{Is i<br>less than or<br>equal to<br>number?}
H -- Yes --> I[Set sum to<br>a + b]
I --> J[Set a to b]
J --> K[Set b to sum]
K --> L[Increase i by 1]
L --> H
H -- No --> M[/b/]
D --> N((End))
M --> N
Algorithm X
Figure 1 represents Algorithm X and makes the loop state visible for tracing. What will be the output if the input—labeled number—is 6?
Choose the correct output:
- 5
- 8
- 13
- 21
- 34