#COMPILE EXE "s40_recursive.exe"
' Sample: Recursive function (factorial)
FUNCTION Factorial(BYVAL n AS LONG) AS LONG
    IF n <= 1 THEN
        FUNCTION = 1
    ELSE
        FUNCTION = n * Factorial(n - 1)
    END IF
END FUNCTION
FUNCTION PBMAIN() AS LONG
    DIM i AS LONG
    PRINT "Factorials 1-5:"
    FOR i = 1 TO 5
        PRINT i; "! ="; Factorial(i)
    NEXT i
    FUNCTION = 0
END FUNCTION
