/**
 * This function takes a range of numbers and a list of elements as input.
 * It then appends the elements to a list only if they are divisible by a number in the given range.
 * Finally, it returns the updated list.
 *
 * @param rangeStart the starting number of the range (inclusive)
 * @param rangeEnd the ending number of the range (exclusive)
 * @param elements a list of elements to append
 * @return A list containing only the elements that are divisible by a number in the given range.
 */
fun addElementsToList(rangeStart: Int, rangeEnd: Int, elements: List<Int>): List<Int> {

    // Create an empty list to store the results
    val resultList = mutableListOf<Int>()

    // Generate range of numbers
    val numbers = (rangeStart until rangeEnd).toList()

    // Iterate through the elements
    for (element in elements) {
        // Iterate through the numbers in the range
        for (num in numbers) {
            // If the element is divisible by the number, append it to the result list
            if (element % num == 0) {
                resultList.add(element)
                break
            }
        }
    }

    return resultList
}
/**
 * This function takes a range of numbers and a list of elements as input.
 * It then appends the elements to a list only if they are divisible by a number in the given range.
 * Finally, it returns the updated list.
 *
 * @param rangeStart the starting number of the range (inclusive)
 * @param rangeEnd the ending number of the range (exclusive)
 * @param elements a list of elements to append
 * @return A list containing only the elements that are divisible by a number in the given range.
 */
fun addElementsToList(rangeStart: Int, rangeEnd: Int, elements: List<Int>): List<Int> {
/**
 * This function takes a range of numbers and a list of elements as input.
 * It then appends the elements to a list only if they are divisible by a number in the given range.
 * Finally, it returns the updated list.
 *
 * @param rangeStart the starting number of the range (inclusive)
 * @param rangeEnd the ending number of the range (exclusive)
 * @param elements a list of elements to append
 * @return A list containing only the elements that are divisible by a number in the given range.
 */
fun addElementsToList(rangeStart: Int, rangeEnd: Int, elements: List<Int>): List<Int> {

    // Create an empty list to store the results
    val resultList = mutableListOf<Int>()

    // Generate range of numbers
    val numbers = (rangeStart until rangeEnd).toList()

    // Iterate through the elements
    for (element in elements) {
        // Iterate through the numbers in the range
        for (num in numbers) {
            // If the element is divisible by the number, append it to the result list
            if (element % num == 0) {
                resultList.add(element)
                break
            }
        }
    }

    return resultList
}