Recursive fibonacci function. : Recursive function : Function PYTHON TUTORIALS


PYTHON TUTORIALS » Function » Recursive function »

 

Recursive fibonacci function.


def fibonacci):

   if n < 0
      print "Cannot find the fibonacci of a negative number"

   if n == or n == 1:  # base case
      return n
   else:
      return fibonaccin - + fibonaccin - )

number = intraw_input"Enter an integer: " ) )
result = fibonaccinumber )
print "Fibonacci(%d) = %d" number, result )



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Function
» Recursive function