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.48 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. num_prev = 1
  13. num = 2
  14. for i in range (0, num-3):
  15. temp = num
  16. num = num + num_prev
  17. num_prev = temp
  18. return num
  19.  
  20. def main():
  21. num = 4
  22. print "Fib_num of number", str(num), ":", str(find_fib_n(num))
  23.  
  24. if __name__=="__main__":
  25. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement