Jump to content

Compile-time calculation: Difference between revisions

No edit summary
Line 705:
=={{header|PowerShell}}==
<lang PowerShell>
function funfact([BigInt]$n){
if($n -gtge 0([BigInt]::Zero)) {
$res = 0
$fact = [BigInt]::One
if($n -gt 0) {
1([BigInt]::One)..$n | foreach{
$a, $bfact = [BigInt]::Multiply($_fact, ($n+$_)
$res += $a + $b
}
$res $fact
 
} else {
Write-Error "$n is lower than 0"
}
$res
}
"$((Measure-Command {fun$fact 10000= fact 10}).TotalSeconds) Seconds"
$fact
</lang>
<b>Output:</b>
<pre>
0.8207120030411 Seconds
3628800
</pre>
 
678

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.