DEV Community

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

Posted on

2 2

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
1.Slow.
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!

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay