Skip to content

Instantly share code, notes, and snippets.

@jsjohnst
Created March 5, 2010 20:08
Show Gist options
  • Save jsjohnst/323089 to your computer and use it in GitHub Desktop.
Save jsjohnst/323089 to your computer and use it in GitHub Desktop.
def collatz(order)
loops = 0
i = rand(10**order)
while i > 1
if i % 2 == 0
i = i / 2
else
i = i * 3 + 1
end
loops+=1
end
puts "Loops: #{loops}"
end
collatz(24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment