daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Jan 14th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #This is a sample fibonacci program
  2. def fibo1(n):
  3.     if n <= 1 :
  4.         return 1
  5.     else :
  6.         return fibo1(n-1) + fibo1(n-2)
  7.  
  8. def fibo2(n):
  9.     if n <= 1:
  10.         return 1
  11.     else :
  12.         answer = 1
  13.         old    = 0
  14.         for x in range(n-1):
  15.             answer,old = answer+old,answer
  16.     return answer
  17.  
  18. print "fibo1:"
  19. for x in range(20):
  20.     print fibo1(x)
  21.  
  22. print "fibo2:"+str(fibo2(20))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top