Skip to content

Instantly share code, notes, and snippets.

@lafeber
Created October 29, 2021 09:45
Show Gist options
  • Save lafeber/6f48b07a726a944adec037c3ec6516c0 to your computer and use it in GitHub Desktop.
Save lafeber/6f48b07a726a944adec037c3ec6516c0 to your computer and use it in GitHub Desktop.
Collatz conjecture
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