RosettaCodeData/Task/Multifactorial/QuickBASIC/multifactorial.basic
2026-04-30 12:34:36 -04:00

23 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