FUNCTION fact(BYVAL n AS LONG) AS LONG
    LOCAL r AS LONG
    r = 1

    IF n = 0 THEN
        fact = 1
    ELSE
        FOR i = 1 TO n
            r = r * i
        NEXT i
        fact = r
    END IF
END FUNCTION

FUNCTION main() AS LONG
    main = fact(5)
END FUNCTION
