/**
 * This function appends new elements to a list and then multiplies each element by a given factor.
 *
 * @param elements A list of existing elements.
 * @param factor The factor to multiply each element by.
 * @return The resulting list after appending new elements and multiplication.
 *
 * Example:
 * appendAndMultiply(listOf(1, 2, 3), 2) returns [1, 2, 3, 4, 6, 8]
 */
fun appendAndMultiply(elements: MutableList<Int>, factor: Int): List<Int> {

    // Appending new elements
    elements.addAll(listOf(10, 20))

    // Multiplying each element by the factor
    for (i in elements.indices) {
        elements[i] *= factor
    }

    return elements
}
/**
 * This function appends new elements to a list and then multiplies each element by a given factor.
 *
 * @param elements A list of existing elements.
 * @param factor The factor to multiply each element by.
 * @return The resulting list after appending new elements and multiplication.
 *
 * Example:
 * appendAndMultiply(listOf(1, 2, 3), 2) returns [1, 2, 3, 4, 6, 8]
 */
fun appendAndMultiply(elements: MutableList<Int>, factor: Int): List<Int> {
/**
 * This function appends new elements to a list and then multiplies each element by a given factor.
 *
 * @param elements A list of existing elements.
 * @param factor The factor to multiply each element by.
 * @return The resulting list after appending new elements and multiplication.
 *
 * Example:
 * appendAndMultiply(listOf(1, 2, 3), 2) returns [1, 2, 3, 4, 6, 8]
 */
fun appendAndMultiply(elements: MutableList<Int>, factor: Int): List<Int> {

    // Appending new elements
    elements.addAll(listOf(10, 20))

    // Multiplying each element by the factor
    for (i in elements.indices) {
        elements[i] *= factor
    }

    return elements
}