RosettaCodeData/Task/Factorial/PowerShell/factorial-2.ps1
2026-04-30 12:34:36 -04:00

9 lines
183 B
PowerShell

function Get-Factorial ($x) {
if ($x -eq 0) {
return 1
} else {
$product = 1
1..$x | ForEach-Object { $product *= $_ }
return $product
}
}