Skip to content

Instantly share code, notes, and snippets.

@HaniKazmi
Last active August 29, 2015 13:56
Show Gist options
  • Save HaniKazmi/8983676 to your computer and use it in GitHub Desktop.
Save HaniKazmi/8983676 to your computer and use it in GitHub Desktop.
def count input
j = input.even? ? input/2 : 3*input + 1
if $results[j].to_i==0; count j end
$results[input] = $results[j] + 1
end
$results = { 1 => 1 }
(2..1000000).each { |i| count i }
puts $results.max_by{ |k,v| v }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment