Created
July 24, 2015 15:14
-
-
Save vznvzn/52536d76b19b98e1d733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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