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!

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs