Skip to content

Instantly share code, notes, and snippets.

@snahor
Created Sep 10, 2017
Embed
What would you like to do?
def fib():
a, b = 0, 1
while True:
yield a
a, b = b, a + b
# Hofstadter Figure-Figure sequences
# F(1) = 1, S(1) = 2
# F(n) = F(n - 1) + S(n - 1)
def fig():
f, s = 1, 2
used = []
while True:
yield f, s
f = f + s
used.append(f)
s += 1
if used[0] == s:
s += 1
used = used[1:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment