Windows PowerShell 5.0
Version of implementation Windows PowerShell of programming language PowerShellVersion of Windows PowerShell released on April 3, 2014. It is available as part of Windows Management Framework 5.0.
Examples:
Hello, World! - PowerShell (504):
Echo "Hello, World!"
Factorial - PowerShell (505):
function Get-Factorial ($n) {
if ($n -eq 0) {
return 1
}
$fact = 1
1..$n | ForEach { $fact *= $_ }
return $fact
}
foreach ($i in 0..16) {
echo ("{0}! = {1}" -f $i,(Get-Factorial $i))
}
Fibonacci numbers - PowerShell (506):
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
]]>