Skip to content

Instantly share code, notes, and snippets.

@amckinley
Last active August 29, 2015 14:25
Show Gist options
  • Save amckinley/12fed59d9ac388872c29 to your computer and use it in GitHub Desktop.
Save amckinley/12fed59d9ac388872c29 to your computer and use it in GitHub Desktop.
def fibsy(n, i, g, s):
if n > 0 and g == 0:
n -= 1
print 0
return fibsy(n, i, 1, s)
elif n > 0 and s == True:
n -= 1
print 1
return fibsy(n, 1, g, False)
elif n > 0:
n -= 1
print g
i, g = g, i + g
return fibsy(n, i, g, s)
else:
print "Finished."
return None
def fib(n):
return fibsy(n, 0, 0, True)
if __name__ == '__main__':
print fib(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment