Posts

Showing posts with the label Fibonacci series

Python Program to Print Fibonacci series - Codicaly

Image
  In this post, we are going to write a program to print the Fibonacci series. General idea :               In mathematics, the  Fibonacci number  is a sequence , called the  Fibonacci sequence , such that each number is the sum of the two preceding ones, starting from 0 and 1. Like 0,1,1,2,3,5,8,13,21........... In this sequence, 0 and 1 are default numbers. Then the sum of 0 and 1 is 1.Then the sum of 1 and 1 is 2. Then the sum of 1 and 2 is 3. Then the sum of 2 and 3 is 5. And so on. Pre-Requisites : Python Basics Iteration ( For loop) Program : n=int(input("Enter the number of terms")) total=0 a=0 b=1 print(a) print(b) for i in range(0,n-2):     total=a+b     print(total)     a=b     b=total Explanation : 1.First we need to input the number of terms we need to print. Here we are doing that using print. 2.Here in these lines we are initializing the total to 0, a to 0, and b to 1. 'a' is the...