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

15 lines
289 B
Text
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
function nth($inp){
$suffix = "th"
switch($inp % 10){
1{$suffix="st"}
2{$suffix="nd"}
3{$suffix="rd"}
}
return "$inp$suffix "
}
0..25 | %{Write-host -nonewline (nth "$_")};""
250..265 | %{Write-host -nonewline (nth "$_")};""
1000..1025 | %{Write-host -nonewline (nth "$_")};""