24 lines
459 B
Text
24 lines
459 B
Text
|
|
' Multi factorial
|
||
|
|
|
||
|
|
DECLARE FUNCTION MultiFactorial& (N%, Degree%)
|
||
|
|
FOR Degree% = 1 TO 5
|
||
|
|
PRINT "Degree"; Degree%; "=>";
|
||
|
|
FOR N% = 1 TO 10
|
||
|
|
PRINT MultiFactorial&(N%, Degree%);
|
||
|
|
NEXT N%
|
||
|
|
PRINT
|
||
|
|
NEXT Degree%
|
||
|
|
END
|
||
|
|
|
||
|
|
FUNCTION MultiFactorial& (N%, Degree%)
|
||
|
|
IF (N% < 2) THEN
|
||
|
|
MultiFactorial& = 1
|
||
|
|
ELSE
|
||
|
|
Result& = N%
|
||
|
|
FOR I% = N% - Degree% TO 2 STEP -Degree%
|
||
|
|
Result& = Result& * I%
|
||
|
|
NEXT I%
|
||
|
|
MultiFactorial& = Result&
|
||
|
|
END IF
|
||
|
|
END FUNCTION
|