Created
September 1, 2016 00:56
-
-
Save vznvzn/7f487a8bf906f9c9f4b7b0c911c1a81e 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) / 2 while (n % 2 == 1) | |
n /= 2 while (n % 2 == 0) | |
return n | |
end | |
def seq2(n) | |
l = [n] | |
n1 = n | |
l << (n = f1(n)) while (n >= n1 && n != 1) | |
return l | |
end | |
l = File.open('grow.txt').readlines | |
l[-10..-1].each\ | |
{ | |
|x| | |
l1 = Kernel.eval(x) | |
l1.each \ | |
{ | |
|z| | |
n = z['n'] | |
l2 = seq2(n).map { |x| x.to_s(2).length } | |
l2.each_with_index { |x, i| puts([i, x - l2[0]].join("\t")) } | |
puts | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment