def closest_factor(value, factor):
    """
    Return the maximum factor of `value` that is no larger than `factor` (if
    any), and the minimum factor of `value` that is no less than `factor` (if
    any), as a tuple.
    """
    if not isinstance(value, int):
        raise TypeError('value must be integers.')
    if value < 0 or factor < 0:
        raise ValueError('arguments must not be negative.')
    res = tuple()
    if factor >= 1:
        f = int(factor) + 1
        while f > factor:
            f -= 1
        while True:
            if f != 0 and value % f == 0:
                break
            f -= 1
        assert f <= factor and value % f == 0
        res += f,
    if factor <= abs(value):
        f = int(factor) - 1
        while f < factor:
            f += 1
        while True:
            if f != 0 and value % f == 0:
                break
            f += 1
        assert f >= factor and value % f == 0
        res += f,
    return res
