def val_closest_to(n: int, val: int) -> int:
    """returns the integer value closest to val that can be divided into n int partitions

    :param n: int, number of partitions
    :param val: int, value to approximate
    :return: int, approximate value closest to val
    """
    n_partitions = val // n
    low, high = val - n_partitions * n, n * (n_partitions + 1) - val
    if low < high:
        return n_partitions * n
    return (n_partitions + 1) * n