Program for Fibonacci Series in Python
What is Fibonacci Series?
The Fibonacci series is a mathematical sequence of numbers in which, each element is the sum of the previous two elements. It starts with zero and one followed by 1, 2, 3, 5, 8, 13, 21, and so on. Each element in this sequence is called a Fibonacci number. In this article, we will see a Python program to print the Fibonacci series in Python. also Fibonacci Series is representation of the beautiful things in nature. such as the Golden Ratio.
Program for Fibonacci Series in Python
A Fibonacci sequence is the integer sequence of 0, 1, 1, 2, 3, 5, 8....
0 and 1 are the two term. All other terms are executed by adding the preceding or last two terms . This means to say the nth term is the sum of (n-1)th and (n-2)th term.
1) Program for Fibonacci Series in Python using If. Else Statement and While loop Without Function
Source Code
Output
Here, we store the number of terms in nth terms. We initialize the first term to 0 and the second term to 1.
If the number of terms is more than 2, we use a while loop to find the next term in the sequence by adding the preceding two terms. We then interchange the variables (update it) and continue on with the process.
2) Program for Fibonacci Series in Python using While Loop without Function
Source Code
Output
1 2 3 5 8 13 21 3455 89
3) Program for Fibonacci Series in Python using If. Else Statement With Function
Source Code
Output
34
Hope you guys Understood this concept and do implement it to your coding platform. and there are many method to program Fibonacci Series in python programming.