Fibonacci Series Program in Python
In this program, we will learn to find the Fibonacci series program in python using the user-defined function. Before to start this you have to know about this:
Fibonacci series is the sequence of 0, 1, 1, 2, 3, 5, 8,……
The first two values are 0 and 1. All other values are obtained by adding the preceding two terms. This means to say the nth term is the sum of (n-1)th and (n-2)th terms.
Fibonacci Series Source Code
def fibonacci_ser(num):
a=0
b=1
if num == 1:
print(a)
elif num == 2 :
print(a, b)
else:
print(a,b,end=" ")
for i in range(num-2):
c=a+b
a=b
b=c
print(b,end=" ")
num1=int(input("enter number to find Fabonacci series: "))
print(f'are fibibonacci of {num1}',fibonacci_ser(num1))
Output:
C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py
enter number to find Fabonacci series: 12
0 1 1 2 3 5 8 13 21 34 55 89 are fibibonacci of 12 None
Process finished with exit code 0
Recommended Post:
- Python Hello World Program
- Python Comment | Creating a Comment | multiline comment | example
- Python Dictionary Introduction | Why to use dictionary | with example
- How to do Sum or Addition in python
- Python Reverse number
- find the common number in python
- addition of number using for loop and providing user input data in python
- Python Count char in String
- Python Last Character from String
- Python Odd and Even | if the condition
- Python Greater or equal number
- Python PALINDROME NUMBER
- Python FIBONACCI SERIES
- Python Dictionary | Items method | Definition and usage
- Python Dictionary | Add data, POP, pop item, update method
- Python Dictionary | update() method
- Delete statement, Looping in the list In Python
- Odd and Even using Append in python
- Python | Simple Odd and Even number
Get Salesforce Answers