Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
34
Task/Multifactorial/Pascal-P/multifactorial.pas
Normal file
34
Task/Multifactorial/Pascal-P/multifactorial.pas
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
program multifactorial(output);
|
||||
|
||||
var
|
||||
n, degree: integer; (* Requires 32-bit integer *)
|
||||
|
||||
function multifactorial(n: integer; degree: integer): integer;
|
||||
var
|
||||
i, res: integer;
|
||||
begin
|
||||
if (n < 2) then
|
||||
multifactorial := 1
|
||||
else
|
||||
begin
|
||||
res := n;
|
||||
i := n - degree;
|
||||
while i >= 2 do
|
||||
begin
|
||||
res := res * i;
|
||||
i := i - degree;
|
||||
end;
|
||||
multifactorial := res;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
for degree := 1 to 5 do
|
||||
begin
|
||||
write('Degree ', degree:1, ' =>');
|
||||
for n := 1 to 10 do
|
||||
write(' ', multifactorial(n, degree):1);
|
||||
writeln;
|
||||
end;
|
||||
(* readln; *)
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue