RosettaCodeData/Task/Factorial/PowerShell/factorial-2.psh

10 lines
183 B
Plaintext

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