Skip to content

Instantly share code, notes, and snippets.

@vznvzn
Created July 24, 2015 15:14
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 vznvzn/52536d76b19b98e1d733 to your computer and use it in GitHub Desktop.
Save vznvzn/52536d76b19b98e1d733 to your computer and use it in GitHub Desktop.
def f1(n)
n = n * 3 + 1 if (n.odd?)
n /= 2 while (n.even?)
return n
end
def run(p)
n = 2 * 3 ** (p - 1) - 1
n = f1(n)
n1 = n
c = 0
while (n >= n1)
c += 1
n = f1(n)
end
return c
end
20000.times { |i| p(run(i + 3)); $stdout.flush }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment