Last active
December 13, 2019 09:50
-
-
Save praserocking/16ad9b7b1c44c88da05e8a24ba4a400a to your computer and use it in GitHub Desktop.
Collatz Conjecture
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
# 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