Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

Fibonacci sum for the given number

Problem description :

In mathematics, the Fibonacci numbers are the numbers in the following integer sequence:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...

In mathematical terms, the sequence F(n) of Fibonacci numbers is defined by the recurrence relation

F(n) = F(n-1) + F(n-2), with seed values F(0) = 0, F(1) = 1, F(2) = 1.

Input : A number >= 0

Output : A Number

Logic :

  • Cached the already calculated fibonacci numbers (aka dynamic programming).
  • If the number is not calculated then call the function again (aka recurssion).

Solution :

You may also like...

1 Response

  1. exponential time complexity with this recursive technique, though. a dynamic bottom-up approach?

Leave a Reply

Your email address will not be published. Required fields are marked *