Fibonacci Numbers
Find the nth number in the Fibonacci sequence.
Statement
Implement a function to find the n Fibonacci number in the Fibonacci sequence.
Fibonacci numbers form a sequence known as the Fibonacci sequence, where each number is the sum of two preceding ones, starting from and .
The Fibonacci numbers are defined as:
- , for
Based on the definition above, the first Fibonacci numbers starting, from the , are: .
Sample input
8
Expected output
21
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.