Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
38
Task/Multifactorial/Modula-2/multifactorial.mod2
Normal file
38
Task/Multifactorial/Modula-2/multifactorial.mod2
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
MODULE Multifactorial;
|
||||
FROM STextIO IMPORT
|
||||
WriteLn, WriteString;
|
||||
FROM SWholeIO IMPORT
|
||||
WriteInt;
|
||||
|
||||
VAR
|
||||
Degree, N: INTEGER;
|
||||
|
||||
PROCEDURE MultiFactorial(N, Degree: INTEGER): INTEGER;
|
||||
VAR
|
||||
Result, I: INTEGER;
|
||||
BEGIN
|
||||
IF (N < 2) THEN
|
||||
RETURN 1
|
||||
ELSE
|
||||
Result := N;
|
||||
I := N - Degree;
|
||||
WHILE I >= 2 DO
|
||||
Result := Result * I;
|
||||
I := I - Degree
|
||||
END;
|
||||
RETURN Result
|
||||
END
|
||||
END MultiFactorial;
|
||||
|
||||
BEGIN
|
||||
FOR Degree := 1 TO 5 DO
|
||||
WriteString("Degree ");
|
||||
WriteInt(Degree, 1);
|
||||
WriteString(" =>");
|
||||
FOR N := 1 TO 10 DO
|
||||
WriteString(" ");
|
||||
WriteInt(MultiFactorial(N, Degree), 1);
|
||||
END;
|
||||
WriteLn;
|
||||
END;
|
||||
END Multifactorial.
|
||||
Loading…
Add table
Add a link
Reference in a new issue