/**
 * Given two numbers, this function returns a list of their common divisors.
 *
 * @param num1 The first number.
 * @param num2 The second number.
 * @return A list of common divisors of the two numbers.
 *
 * Example:
 * commonDivisors(12, 18) -> [1, 2, 3, 6]
 * commonDivisors(24, 36) -> [1, 2, 3, 4, 6, 12]
 */
fun commonDivisors(num1: Int, num2: Int): List<Int> {

    val divisors1 = (1..num1).filter { num1 % it == 0 }
    val divisors2 = (1..num2).filter { num2 % it == 0 }

    return divisors1.filter { it in divisors2 }
}
/**
 * Given two numbers, this function returns a list of their common divisors.
 *
 * @param num1 The first number.
 * @param num2 The second number.
 * @return A list of common divisors of the two numbers.
 *
 * Example:
 * commonDivisors(12, 18) -> [1, 2, 3, 6]
 * commonDivisors(24, 36) -> [1, 2, 3, 4, 6, 12]
 */
fun commonDivisors(num1: Int, num2: Int): List<Int> {
/**
 * Given two numbers, this function returns a list of their common divisors.
 *
 * @param num1 The first number.
 * @param num2 The second number.
 * @return A list of common divisors of the two numbers.
 *
 * Example:
 * commonDivisors(12, 18) -> [1, 2, 3, 6]
 * commonDivisors(24, 36) -> [1, 2, 3, 4, 6, 12]
 */
fun commonDivisors(num1: Int, num2: Int): List<Int> {

    val divisors1 = (1..num1).filter { num1 % it == 0 }
    val divisors2 = (1..num2).filter { num2 % it == 0 }

    return divisors1.filter { it in divisors2 }
}