Notice removed Reward existing answer by xnor
Bounty Ended with xsot's answer chosen by xnor
Bounty Started worth 500 reputation by xnor
2 tagging as code golf per "What is the smallest algorithm for this?"
1

# 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?