Skip to content

Instantly share code, notes, and snippets.

@hellonico
Last active August 29, 2015 14:19
Show Gist options
  • Save hellonico/d549832db8a326460ce5 to your computer and use it in GitHub Desktop.
Save hellonico/d549832db8a326460ce5 to your computer and use it in GitHub Desktop.
Tak in nim
var
i:int = 0
proc tak(x, y, z:int):int =
if x <= y:
y
else:
i = i + 1
tak(tak(x-1, y, z),tak(y-1, z, x),tak(z-1, x, y))
proc takeuchi_number(n:int):int =
i = 0
discard tak(n,0,n+1)
i
when isMainModule:
echo(takeuchi_number(14))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment