Last active
August 29, 2015 14:19
-
-
Save hellonico/d549832db8a326460ce5 to your computer and use it in GitHub Desktop.
Tak in nim
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
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