/**
 * This exercise aims to modify a given list using loops and built-in functions in Kotlin.
 * The function takes in a list of integers 'numList' and an integer 'n'.
 * It removes all numbers from the list that are greater than 'n' and multiplies the remaining numbers by n.
 * The modified list is returned as the output.
 *
 * Example:
 * numList = [1, 5, 10, 2, 7, 3]
 * n = 5
 *
 * The output will be:
 * [5, 10, 3, 5]
 */
fun modifyListWithLoops(numList: MutableList<Int>, n: Int): List<Int> {

    val iterator = numList.iterator()
    while (iterator.hasNext()) {
        val num = iterator.next()
        if (num > n) {
            iterator.remove()
        } else {
            numList[numList.indexOf(num)] = num * n
        }
    }
    return numList
}
/**
 * This exercise aims to modify a given list using loops and built-in functions in Kotlin.
 * The function takes in a list of integers 'numList' and an integer 'n'.
 * It removes all numbers from the list that are greater than 'n' and multiplies the remaining numbers by n.
 * The modified list is returned as the output.
 *
 * Example:
 * numList = [1, 5, 10, 2, 7, 3]
 * n = 5
 *
 * The output will be:
 * [5, 10, 3, 5]
 */
fun modifyListWithLoops(numList: MutableList<Int>, n: Int): List<Int> {
/**
 * This exercise aims to modify a given list using loops and built-in functions in Kotlin.
 * The function takes in a list of integers 'numList' and an integer 'n'.
 * It removes all numbers from the list that are greater than 'n' and multiplies the remaining numbers by n.
 * The modified list is returned as the output.
 *
 * Example:
 * numList = [1, 5, 10, 2, 7, 3]
 * n = 5
 *
 * The output will be:
 * [5, 10, 3, 5]
 */
fun modifyListWithLoops(numList: MutableList<Int>, n: Int): List<Int> {

    val iterator = numList.iterator()
    while (iterator.hasNext()) {
        val num = iterator.next()
        if (num > n) {
            iterator.remove()
        } else {
            numList[numList.indexOf(num)] = num * n
        }
    }
    return numList
}