Recursive fibonacci function. : Function Recursive : Buildin Function PYTHON examples


PYTHON examples » Buildin Function » Function Recursive »

 

Recursive fibonacci function.


Recursive fibonacci function.




def fibonacci):

   if n == or n == 1:  # base case
      return n
   else:

      # two recursive calls
      return fibonaccin - + fibonaccin - )

number = intraw_input"Enter an integer: " ) )

if number > 0:
   result = fibonaccinumber )
   print "Fibonacci(%d) = %d" number, result )
else:
   print "Cannot find the fibonacci of a negative number"
 

           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Buildin Function
» Function Recursive