Farz0l1x

Untitled

Jul 23rd, 2022
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. def fib(n):
  2.     a_prev = 1
  3.     a_cur = 1
  4.     for i in range(2, n + 1):
  5.         a_new = a_cur + a_prev
  6.         a_prev = a_cur
  7.         a_cur = a_new
  8.     return a_cur
  9. print(fib(4))
Advertisement
Add Comment
Please, Sign In to add comment