Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
    Notice removed Reward existing answer by xnor
    Bounty Ended with xsot's answer chosen by xnor
    Notice added Reward existing answer by xnor
    Bounty Started worth 500 reputation by xnor
    Tweeted twitter.com/#!/StackCodeGolf/status/160639055841853441
2 tagging as code golf per "What is the smallest algorithm for this?"
| link
1
source | link

Outputting ordinal numbers (1st, 2nd, 3rd)

I would like to generate (as a return result of a function, or simply as the output of a program) the ordinal suffix of a positive integer concatenated to the number.

Samples:

1st  
2nd  
3rd  
4th  
...  
11th  
12th  
13th  
...  
20th  
21st
22nd
23rd
24th

And so on, with the suffix repeating the initial 1-10 subpattern every 10 until 100, where the pattern ultimately starts over.

The input would be the number and the output the ordinal string as shown above.

What is the smallest algorithm for this?