Posts

Showing posts with the label Fibonacci Number

Fibonacci Number Using Recursion Method

Image
Fibonacci series is a series of numbers formed by the addition of the preceeding two numbers in the series. Examples of Fibonacci Series: 0+1+1+2+3+5.... 0 and 1 are the first two terms of the series. These two terms are printed directly. The third term is calculated by adding the first two terms. In this case 0 and 1. So, we get 0+1=1. Hence 1 is printed as the third term. The next term is generated by using the second and third term and not using the first term. n=int( input ( "Enter the Number:"  )) def   Fib ( n ):     if  n== 1 :          return   0      elif  n== 2 :          return   1      elif  n<= 0 :          return  ( "Invalid" )      else :         return(Fib(n -1 )+Fib(n -2 ))   ...