def int2roman(val):
    """Code roman number

    :param val: integer between 1 and 9999
    :returns: the corresponding roman number
    :complexity: linear (if that makes sense for constant bounded input size)
    """
    s = ''
    pos10 = 1000
    for pos in range(3, -1, -1):
        digit = val // pos10
        s += roman[pos][digit]
        val %= pos10
        pos10 //= 10
    return s
Code roman number

    :param val: integer between 1 and 9999
    :returns: the corresponding roman number
    :complexity: linear (if that makes sense for constant bounded input size)