Write a function/method/subroutine/... that when given an integer greater than or equal to zero returns a string of the number followed by an apostrophe then the ordinal suffix.



Example

Returns would include 1'st 2'nd 3'rd 11'th 111'th 1001'st 1012'th



Task

Use your routine to show here the output for at least the following (inclusive) ranges of integer inputs:
0..25, 250..265, 1000..1025


Note: apostrophes are now optional to allow correct apostrophe-less English.




 
PROGRAM "nth"
VERSION "0.0002"
 
DECLARE FUNCTION  Entry()
INTERNAL FUNCTION Suffix$(n&&)
INTERNAL FUNCTION PrintImages (loLim&&, hiLim&&)
 
FUNCTION Entry()
  PrintImages(   0,   25)
  PrintImages( 250,  265)
  PrintImages(1000, 1025)
END FUNCTION
 
FUNCTION Suffix$(n&&)
  nMod10@@ = n&& MOD 10
  nMod100@@ = n&& MOD 100
  SELECT CASE TRUE
    CASE (nMod10@@ = 1) AND (nMod100@@ <> 11):
      RETURN ("st")
    CASE (nMod10@@ = 2) AND (nMod100@@ <> 12):
      RETURN ("nd")
    CASE (nMod10@@ = 3) AND (nMod100@@ <> 13):
      RETURN ("rd")
    CASE ELSE:
      RETURN ("th")
  END SELECT
END FUNCTION
 
FUNCTION PrintImages(loLim&&, hiLim&&)
  FOR i&& = loLim&& TO hiLim&&
    PRINT TRIM$(STRING$(i&&)); Suffix$(i&&); " ";
  NEXT
  PRINT
END FUNCTION
END PROGRAM
 