Skip to content

Instantly share code, notes, and snippets.

@snahor
Created September 10, 2017 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snahor/eb844da9d289715b9000f8f1148c0f22 to your computer and use it in GitHub Desktop.
Save snahor/eb844da9d289715b9000f8f1148c0f22 to your computer and use it in GitHub Desktop.
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