\ $Id: ackermann.gforth,v 1.2 2001/05/25 16:43:25 doug Exp $
\ ackermann's function
\ http://www.bagley.org/~doug/shootout/

\ read NUM from last command line argument
0. argc @ 1- arg >number 2drop drop constant NUM

: ack  recursive
    dup 0=
    if
    drop 1+
    else
    swap dup 0=
    if
        drop 1- 1 swap ack
    else
        1- over 1- rot rot swap ack swap ack
    then
    then ;
\ END ACK

\ run ack(3, NUM) and print result from stack
." Ack: " NUM 3 ack 1 u.r cr

bye \ th-th-that's all folks!