CENG4313
Fall 2015
Midterm Exam
Q3 (25 points)
Fibonacci number.
The subroutine, nfibo, accepts n as an input in RO and returns the corresponding Fibonacci number at the n-th position in RO. Don't try to use an array to map as Fibonacci is an infinite series. This programming can be done with loops or a recursive subroutine. Recursive subroutine is shorter and easier to write than loops, but both are doable. You can choose either method. As always, the subroutine should preserve all the registers except the return/output register. F4 F5 F6 F7 38 FO F10 FO F F2 -3 8 13 21 34 55 68
For example, if n=3, the return value would be 2. If n=6, the return value would be 8.