Skip to content

Instantly share code, notes, and snippets.

@vznvzn
Created August 14, 2015 18:51
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/f2e76460f0883ffbe5b8 to your computer and use it in GitHub Desktop.
Save vznvzn/f2e76460f0883ffbe5b8 to your computer and use it in GitHub Desktop.
def power(x, p)
n = n1 = x ** p
w = n.to_s(2).length
c = 0
while (n != 1 && n >= n1)
n = n * 3 + 1 if (n.odd?)
n /= 2 while (n.even?)
c += 1
end
return w, c
end
def out(x, c)
50.times \
{
|i|
puts(power(x, i * 2 + 1).join("\t"))
}
end
t = 1024 + 3
50.times \
{
|i|
out(t, i)
t += 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment