PowerShell
- Appeared in:
- November 14, 2006
- Paradigm:
- Typing discipline:
- File extensions:
- .ps1
- Versions and implementations (Collapse all | Expand all):
PowerShell is a scripting language developed by Microsoft.
Links:
Examples:
Hello, World!:
Example for versions Windows PowerShell 5.0Echo "Hello, World!"
Factorial:
Example for versions Windows PowerShell 5.0function 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:
Example for versions Windows PowerShell 5.0function 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
]]>