Exercise 13 - 02/14/2017
This exercise demonstrates recursive functions.
A Fibonacci number F(n) is defined as the sum of the first n numbers of the Fibonacci sum. The Fibonacci sum is a infinite sum where the current term is the sum of the previous 2 terms .
Write a recursive function to return the nth Fibonacci number, using the following definition:
F(0) = 0
F(1) = 1
F(n) = F(n-1) + F(n-2)
Also write the main function to call the Fibonacci function.
Sample Run:
Enter the index: 6
The 6th Fibonacci number is : 8
//Explanation: The series is 0, 1, 1, 2, 3, 5, 8, 13, 21 ...
0 indexed, so the 6th number is 8