Skip to content

Instantly share code, notes, and snippets.

@praserocking
Last active December 13, 2019 09:50
Show Gist options
  • Save praserocking/16ad9b7b1c44c88da05e8a24ba4a400a to your computer and use it in GitHub Desktop.
Save praserocking/16ad9b7b1c44c88da05e8a24ba4a400a to your computer and use it in GitHub Desktop.
Collatz Conjecture
# Collatz Conjecture
n = gets.chomp.to_i
loop do
break if n == 1
n = n%2 == 0 ? n/2 : 3*n+1
p n
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment