def ordinal_number(n: int):
    """
    Returns a string representation of the ordinal number for `n`

    e.g.,
    >>> ordinal_number(1)
    '1st'
    >>> ordinal_number(4)
    '4th'
    >>> ordinal_number(21)
    '21st'
    """
    # from https://codegolf.stackexchange.com/questions/4707/outputting-ordinal-numbers-1st-2nd-3rd#answer-4712
    return'%d%s' % (n, 'tsnrhtdd'[(n // 10 % 10 != 1) * (n % 10 < 4) * (n % 10)::4])