Skip to content

Instantly share code, notes, and snippets.

@skalnik
Created October 11, 2008 21:03
Show Gist options
  • Save skalnik/16325 to your computer and use it in GitHub Desktop.
Save skalnik/16325 to your computer and use it in GitHub Desktop.
class Integer
def even?
self % 2 == 0
end
end
highest, num = 0, 0
(1..1_000_000).each { |i|
original, count = i, 0
until i == 1
if i.even?
i = i / 2
else
i = 3 * i + 1
end
count += 1
end
if count > highest
num = original
highest = count
end
}
puts "#{num}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment