Fibonacci numbers in PowerShell
Example for versions
Windows PowerShell 5.0
function Get-Fibonacci ($n) {
if ($n -le 1) {
return 1
}
return (Get-Fibonacci ($n - 1)) + (Get-Fibonacci ($n - 2))
}
$output = ""
foreach ($i in 0..15) {
$output += ("{0}, " -f (Get-Fibonacci $i))
}
echo "$output..."
Comments
]]>blog comments powered by Disqus
]]>