Fibonacci Numbers
Let's solve the Fibonacci Numbers problem using Dynamic Programming.
Statement
Fibonacci numbers are a sequence of numbers where each number is the sum of the two preceding numbers. Your task is to find the Fibonacci number.
The Fibonacci sequence is defined as:
for 2 |
---|
Let’s say you have to find the fifth Fibonacci number in the sequence. From the sequence defined above, we know that and . So, the sequence will be:
Now, the fifth term will be 5.
Constraints:
-
n
Examples
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.