REM
REM Factorial numbers - 8/8/2009 - PvE.
REM Recursive function demonstration.
REM Revised November 2009.
REM

FUNCTION factorial(FLOATING n) TYPE FLOATING

    IF n > 1 THEN
        RETURN n * factorial(n-1)
    END IF

    RETURN 1.0

END FUNCTION

SPLIT ARGUMENT$ BY " " TO arg$ SIZE dim

IF dim < 2 THEN
    PRINT "Usage: factorial <value>"
    END
END IF

PRINT factorial(VAL(arg$[1])) FORMAT "%.0lf\n"