( Recursion)
( 9th April 2016)

( Duplicate if non-zero)
( : ?DUP  DUP 0= 0= IF DUP ENDIF ;)

( Recursive example: list numbers from 1 to n)
( n...)
R: COUNTS  ?DUP IF DUP 1- COUNTS CR . ENDIF R;

( Factorial example:)
R: (FACT)  ( n1,n2...n3)
   ?DUP IF  DUP ROT *
            SWAP 1-
            (FACT)
        ENDIF R;

: FACT   ( n...factorial n)
   1 SWAP (FACT)
   CR . ;


CR ." Try eg '10 COUNTS<CR>' OR '4 FACT<CR>'" CR


( ---------------------)
