Last active
April 29, 2020 13:10
-
-
Save AspenForester/018fec337ff494638d77555a745c4846 to your computer and use it in GitHub Desktop.
Factorial with PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Factorial ([bigint]$x) | |
{ | |
if ($x -ge 1) | |
{ | |
return $x * (Factorial ($x = $x - 1)) | |
} | |
elseif ($x -eq 0) | |
{ | |
return 1 | |
} | |
else | |
{ | |
throw "NaN" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for posting