Last active
August 29, 2015 13:56
-
-
Save HaniKazmi/8983676 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 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