After the following program is executed, cell #3 will contain the 6th Fibonacci number (5).

We need at least 2 numbers before we can calculate sums, so we start with 0 and 1. But notice that 5 is the sum of the two previous numbers 2 and 3.

Instructions
Memory Cells
Program Counter Time
0 0
LW Computer Simulator

Memory cell #1 contains the nth Fibonacci number (initially the 1st Fibonacci number 0).

Cell #2 contains the n + 1th Fibonacci number (initially the 2nd Fibonacci number 1).

Memory cell #4 contains the current count or index.

Cell #5 contains 4. In each iteration, the computer will increment #4 and finish when it reaches the value in cell #5.

The computer computes the next Fibonacci number by adding values in cells #1 and #2 and storing it in cell #3. Then, to prepare for the next iteration, the values are "moved down" 1: cell #2 is copied to cell #1 and cell #3 is copied to cell #2.

Then the counter increments by 1, and the computer jumps back to instruction #4, and the next iteration begins.

At the end of the program, cell #3 contains the 6th Fibonacci number.

Quiz (1 point)

Given that:
the PC at time 0 = 0
instruction #0 is addi dst=1 src=0 imm=0
instruction #1 is addi dst=2 src=0 imm=1
instruction #2 is addi dst=4 src=0 imm=0
instruction #3 is addi dst=5 src=0 imm=4
instruction #4 is add dst=3 src1=1 src2=2
instruction #5 is addi dst=1 src=2 imm=0
instruction #6 is addi dst=2 src=3 imm=0
instruction #7 is addi dst=4 src=4 imm=1
instruction #8 is beq left=4 right=5 imm=1
instruction #9 is jump imm=4

Prove that:
value of cell 3 at time 25 = 5

The following properties may be helpful:

Please write your proof in the table below. Each row should contain one claim. The last claim is the statement that you are trying to prove.

Step Claim Reason (optional) Error Message (if any)
1
2
3
4
5
6
7
8
9
10

Become a subscriber to save your progress, see the correct answer, and more!