Last active
May 19, 2019 01:48
-
-
Save att288/f536e88940ab20d1cd2220db63f1efc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib(n): | |
if n == 0: | |
return 0 | |
if n == 1: | |
return 1 | |
fn_2 = 0 | |
fn_1 = 1 | |
for i in range(n-1): | |
fn = fn_1 + fn_2 | |
fn_2 = fn_1 | |
fn_1 = fn | |
return fn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment