Skip to content

Instantly share code, notes, and snippets.

@DrunkenAlcoholic
Created May 14, 2024 04:08
Show Gist options
  • Save DrunkenAlcoholic/a99edd9f82590295702a356460c61caa to your computer and use it in GitHub Desktop.
Save DrunkenAlcoholic/a99edd9f82590295702a356460c61caa to your computer and use it in GitHub Desktop.
Collatz Conjecture [Exercism - Nim]
proc steps*(n: int): int =
if n < 1: raise (ref ValueError)()
var Num = n
while Num > 1:
inc(result)
if Num mod 2 == 0:
Num = Num div 2
else:
Num = Num * 3 + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment