def METHOD_NAME(num, target):
    """Find the nearest factor of the given number that is smaller than the target."""
    for i in range(target, 0, -1):
        if num % i == 0:
            return i
    # Unreachable because i=1 must hold.
    return -1