Ordinal numbers
Jump to navigation
Jump to search
Ordinal numbers are words used to denote an item's rank or place in an ordered list. Numbers ending in 1, 2, or 3, with the exception of 11, 12, and 13, use the endings "st", "nd", and "rd" respectively, with all other numbers using "th".
1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th, 10th, 11th, 12th, 13th, 14th, 15th, 16th, 17th, 18th, 19th, 20th, 21st, 22nd, 23rd, 24th, ...
Implementations
Lua
v=io.read()print(v..(({"st","nd","rd"})[v:match"1?.$"+0]or"th"))