Created
October 29, 2021 09:45
-
-
Save lafeber/6f48b07a726a944adec037c3ec6516c0 to your computer and use it in GitHub Desktop.
Collatz conjecture
This file contains hidden or 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 collatz(i) | |
puts i | |
return if i==1 | |
i.odd? ? collatz(3*i+1) : collatz(i/2) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment