RosettaCodeData/Task/Nth/PowerShell/nth-2.psh

18 lines
429 B
Plaintext

function Get-Nth ([int]$Number)
{
$suffix = "th"
switch ($Number % 10)
{
1 {$suffix = "st"}
2 {$suffix = "nd"}
3 {$suffix = "rd"}
}
"$Number$suffix"
}
1..25 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force
251..265 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force
1001..1025 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force