Last active
August 29, 2015 13:57
-
-
Save booox/9701963 to your computer and use it in GitHub Desktop.
Fibonacci_1
This file contains hidden or 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
# Fibonacci | |
def fab_1(n): | |
n1 = 1 | |
n2 = 1 | |
n3 = 1 | |
if n < 1: | |
print ('Wrong input,try again!') | |
return -1 | |
while (n-2) > 0: | |
n3 = n2 + n1 | |
n1 = n2 | |
n2 = n3 | |
n -= 1 | |
return n3 | |
result = fab_1(34) | |
if result != -1: | |
print (result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment