First page Back Continue Last page Overview Graphics

Forth Language

Recursion Example:



\ Find the greatest common divisor of two
\ integers

: gcd  ( n1 n2 -- gcd ) 
    ?DUP IF SWAP OVER MOD RECURSE THEN ;

1050 432 gcd .

From A Beginner's Guide to Forth by J. V. Noble