Question: Computer Assignment, Part 2 Program 1 1 : Fibonacci Sequence In mathematics, the Fibonacci sequence is a sequence in which each number is the sum

Computer Assignment, Part 2
Program 11: Fibonacci Sequence
In mathematics, the Fibonacci sequence is a sequence in which each number is the sum of the two preceding ones. Numbers that are part of the Fibonacci sequence are known as Fibonacci numbers, commonly denoted Fn. The sequence commonly starts from 0 and 1, and the sequence begins as:
0,1,1,2,3,5,8,13,21,34,55,89,144,...
The Fibonacci numbers, Fn, may be defined by the recurrence relation
F0=0, F1=1,
and for n >1.
Fn = Fn+1+ Fn+2
Write a recursive function to generate the nth Fibonacci number. The function takes one parameter: the current index value, and returns two results, Fn and Fn-1. Upon entering the function, the current index is checked. If the index is 1 or less, the function returns F0=0, F1=1. Otherwise, the function calls itself, but now sets the argument to be the index value minus one. Upon return, the function continues by adding the two returned values together to form Fn. The function then returns Fn and Fn-1.
Write the main program that calls the Fibonacci function to compute the 30th Fibonacci number. Using our primative library of functions, print the 30th Fibonacci number to the terminal. Also develop the makefile to build the code into an executable.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!