Skip to content

Instantly share code, notes, and snippets.

@hisui
Last active September 3, 2017 08:28
Show Gist options
  • Save hisui/7c2e04dd946dafd572d2ab0e184b24cf to your computer and use it in GitHub Desktop.
Save hisui/7c2e04dd946dafd572d2ab0e184b24cf to your computer and use it in GitHub Desktop.
from itertools import *
for e in takewhile(lambda e: e != 1, accumulate(chain([7], count()), lambda n, _: n // 2 if (n % 2) == 0 else n * 3 + 1)):
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment