diff options
Diffstat (limited to 'tests/misc/tack.nim')
-rw-r--r-- | tests/misc/tack.nim | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/misc/tack.nim b/tests/misc/tack.nim index 680ff567e..a0afab9e8 100644 --- a/tests/misc/tack.nim +++ b/tests/misc/tack.nim @@ -2,20 +2,20 @@ discard """ file: "tack.nim" output: "125" """ -# the Ackermann function - -proc ack(x, y: int): int = - if x != 0: - if y != 0: - return ack(x-1, ack(x, y-1)) - return ack(x-1, 1) - else: - return y + 1 -# if x == 0: return y + 1 -# elif y == 0: return ack(x-1, 1) -# else: return ack(x-1, ack(x, y-1)) - -# echo(ack(0, 0)) -write(stdout, ack(3, 4)) #OUT 125 +# the Ackermann function + +proc ack(x, y: int): int = + if x != 0: + if y != 0: + return ack(x-1, ack(x, y-1)) + return ack(x-1, 1) + else: + return y + 1 +# if x == 0: return y + 1 +# elif y == 0: return ack(x-1, 1) +# else: return ack(x-1, ack(x, y-1)) + +# echo(ack(0, 0)) +write(stdout, ack(3, 4)) #OUT 125 |