Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
20
Task/Multifactorial/PHP/multifactorial.php
Normal file
20
Task/Multifactorial/PHP/multifactorial.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
// Multifactorial
|
||||
for ($degree = 1; $degree <= 5; $degree++) {
|
||||
echo 'Degree '.$degree.' => ';
|
||||
for ($n = 1; $n <= 10; $n++)
|
||||
echo multifactorial($n, $degree).' ';
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
function multifactorial (int $n, int $degree): int {
|
||||
if ($n < 2)
|
||||
return 1;
|
||||
else {
|
||||
$result = $n;
|
||||
for ($i = $n - $degree; $i >= 2; $i -= $degree)
|
||||
$result = $result * $i;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue