Skip to content

Instantly share code, notes, and snippets.

@booox
Last active August 29, 2015 13:57
Show Gist options
  • Save booox/9701963 to your computer and use it in GitHub Desktop.
Save booox/9701963 to your computer and use it in GitHub Desktop.
Fibonacci_1
# 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