We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Ordinal numbers

From Esolang
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

Countable

0+2
1+3
2+4

1*1<
  2*i<
    a2@
    *aa2<
      0+1 1+1 2+1
      2&
    >
    1&
  >
>

256*1<
  49*1<
    aa0&
    49*1< 50*1< 51*1<
      aa1&
      %116 %104
      256&
    >
      %114 %100
      256&
    >
      %110 %100
      256&
    >
      %115 %116
      256&
  >
  %116 %104
>

Lua

v=io.read()print(v..(({"st","nd","rd"})[v:match"1?.$"+0]or"th"))