A3-a: Fibonacci Calculator
250 points
CMake targets: a3a-iter
a3a-rec
You can receive points for either A3-a or A3-b, but not both!
0, 1, 1, 2, 3, 5, 8, 13, ... The Fibonacci Sequence may very well be one of the simplest yet intriguing sequences of numbers out there. Not only can it be found in nature in various forms but it also has some peculiar mathematical properties (for those interested, this page gives a nice overview).
This assignment consists of two different implementations for the same function. Implement a subroutine with the following signature:
Use the a3a-fib-iter.S
file to give an iterative implementation and the a3a-fib-rec.S
file for a recursive implementation. Further, use the a3a-fib-main.S
file to give a simple main
routine that gets a number from the user, calls the subroutine, and then pretty-prints the returned result. The output (for both versions) should look like this:
where <i>
is the given input and <fib(i)>
is the number in the Fibonacci sequence at index i
.
Note for using the Framework
The two targets a3a-iter
and a3a-rec
are entirely separate executables, that use the same main subroutine defined in a3a-fib-main.S
. The only difference between the two is the implementation of the my_fib
subroutine.
When debugging, make sure to select the correct target for the executable you are currently working on. Namely, for a3a-iter
select Debug A3A Fibonacci Iterative and for a3a-rec
select Debug A3a Fibonacci Recursive.
Last updated