A number sequence
The program below builds a sequence of numbers.
a = 1b = 1for n = 1 to 4c = a + ba = bb = cnext nprint(b)
the trace table: one row for the end of each pass, then one row for the print.
| n | a | b | c | output |
|---|---|---|---|---|
| 1 | 1 | 2 | 2 | |
the value printed if the loop runs for n = 1 to 6.
why the order of lines 5 and 6 matters.
a loop that prints every even number from 2 to 20.