Posts

Showing posts from November, 2020

Fibonacci series in python

Image
Fibonacci Series Fibonacci series is 0,1,1,2,3,5,8,13,21,34,............,infinity . It is a sequence of number which follow some type of algorithm the alogrithm is  let  i = index position  a = it is a array of number  so to find a[i+1] = a[i]+a[i-1]. Note : fibonacci series always start with 0 and 1 and goes upto infinity.you can't start with your own values. Explanation: 1. 0 and 1 in starting is default values  2. if we go further the algorithm start adding previous 2 value and the answer is the next value.     as you can see the previous two value is 0 and 1 after adding both we get 1 as our 3rd value.     after that adding 1 and 1 we get our 4th value as 2 this entire cycle goes like this only. i think you get better understanding about fibonacci series we move further on coding of fibo  in python: Flowchart: coding: without recursion function: def fibonacci(n):      a = 0      b = 1      if n < = 0 :          print ( "Incorrect input" )      else :