Python program to print fibonacci series

Fibonacci Series

It is a series of numbers in which each number is the sum of two preceding numbers.This sequence begins with 0 & 1 and each new number is formed by adding preceding two numbers.

Example:- 0,1,1,2,3,5,8,13,21......

To write and execute the code we will need python interpreter.If you haven't installed it yet download it from https://www.python.org/downloads/ and if you want a guide on how to install you can checkout here.

So let's begin with the code


num = int(input("Enter the number of elements required in the series:")) 
a=0 
b=1 
for i in range(num): 
 if i==0 or i==1: 
  print(i) 
 else:
  c=a+b
  print(c) 
  a=b
  b=c


Output





Conclusion

In this post you will get to know about fibonacci series and you will learn to write a python program to print fibonacci series.If you have any queries regarding program or the article you can comment below.
Previous
Next Post »