Compile-time calculation: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 705: | Line 705: | ||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
<lang PowerShell> |
<lang PowerShell> |
||
function |
function fact([BigInt]$n){ |
||
⚫ | |||
$res = 0 |
|||
$fact = [BigInt]::One |
|||
⚫ | |||
([BigInt]::One)..$n | foreach{ |
|||
$ |
$fact = [BigInt]::Multiply($fact, $_) |
||
$res += $a + $b |
|||
} |
} |
||
⚫ | |||
} else { |
|||
Write-Error "$n is lower than 0" |
|||
} |
} |
||
⚫ | |||
} |
} |
||
"$((Measure-Command { |
"$((Measure-Command {$fact = fact 10}).TotalSeconds) Seconds" |
||
$fact |
|||
</lang> |
</lang> |
||
<b>Output:</b> |
<b>Output:</b> |
||
<pre> |
<pre> |
||
0. |
0.0030411 Seconds |
||
3628800 |
|||
</pre> |
</pre> |
||