Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. # Hello World program in Python
  2.  
  3. def find_fib_n(num):
  4. if num < 0:
  5. return 0
  6. if num < 1:
  7. return 1
  8. if num < 2:
  9. return 1
  10. if num < 3:
  11. return 2
  12. total = 2
  13. total_prev = 1
  14. temp = 0
  15.  
  16. for i in range (0, num-3):
  17. temp = total
  18. total += total_prev
  19. total_prev = temp
  20. return total
  21.  
  22. def main():
  23. num = 8
  24. print "Fib_num of number", str(num), ":", str(find_fib_n(num))
  25.  
  26. if __name__=="__main__":
  27. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement