Question: The Fibonacci sequence 1 , 1 , 2 , 3 , 5 , 8 , 1 3 , 2 1 . . . . .

The Fibonacci sequence 1,1,2,3,5,8,13,21...... starts with two 1s, and each term afterwards is the sum of its two predecessors. Please write a function, Fib(n), which takes n as the input parameter. It will return the n-th number in the Fibonacci sequence.
Testing commands: Fib(1); Fib(2); Fib(100)
1. Use loop
2. Use recursion

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 Databases Questions!