Skip to content

Instantly share code, notes, and snippets.

@macbre
Created February 22, 2019 08:56
Show Gist options
  • Save macbre/5e42042f9836194453f10bc8fd3189b3 to your computer and use it in GitHub Desktop.
Save macbre/5e42042f9836194453f10bc8fd3189b3 to your computer and use it in GitHub Desktop.
Loko-ciąg
#!/usr/bin/python
def get_iters_count(n):
i = 0
while True:
i += 1
# print(i, n)
if n == 1:
break
if n % 2 == 0:
n = n/2
else:
n = 3*n + 1
return i
for n in xrange(1, 1024):
iters = get_iters_count(n)
if iters > 100:
print("%5d %5d %s" % (n, iters, '=' * (iters / 2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment