DEV Community

Cover image for Program of fibonacci numbers (method 1)
Mayank singh verma
Mayank singh verma

Posted on

Program of fibonacci numbers (method 1)

Hello guys,
I know most of you heard of the famous Fibonacci numbers. Here we will implement it with Python.
Fibonacci numbers are the sequence of integers(0,1,1,2,3,5,8,13,21,....).
Sequence of integers is defined by the following recurrence relation. F(n)=F(n-1)+F(n-2)
with the values F(0)=0 and F(1)=1

Alt Text

Recursion is a way of programming or coding a problem, in which a function calls itself one or more times in its body. Usually, it is returning the return value of this function call. If a function definition fulfils the condition of recursion, we call this function a recursive function.

Disadvantages of Python Recursion
2.Logical but difficult to trace and debug.
3.Requires extra storage space. For every recursive calls separate memory is allocated for the variables.
4.Recursive functions often throw a Stack Overflow Exception when processing or operations are too large.

Hope you are finding it interesting as well.
Keep Coding: Let me know your thoughts.
Have a great one!

Top comments (0)