/**
 * Given two positive integers 'a' and 'b', find all the common factors of 'a' and 'b'.
 *
 * @param a a positive integer
 * @param b a positive integer
 * @return a list of common factors of 'a' and 'b'
 *
 * Example:
 * findCommonFactors(12, 18)
 * Expected Output: [1, 2, 3, 6]
 */
fun findCommonFactors(a: Int, b: Int): List<Int> {

    val commonFactors = mutableListOf<Int>()

    // Iterate from 1 to the minimum of 'a' and 'b'
    for (i in 1..minOf(a, b)) {
        // Check if 'i' is a factor of both 'a' and 'b'
        if (a % i == 0 && b % i == 0) {
            commonFactors.add(i)
        }
    }

    return commonFactors
}
/**
 * Given two positive integers 'a' and 'b', find all the common factors of 'a' and 'b'.
 *
 * @param a a positive integer
 * @param b a positive integer
 * @return a list of common factors of 'a' and 'b'
 *
 * Example:
 * findCommonFactors(12, 18)
 * Expected Output: [1, 2, 3, 6]
 */
fun findCommonFactors(a: Int, b: Int): List<Int> {
/**
 * Given two positive integers 'a' and 'b', find all the common factors of 'a' and 'b'.
 *
 * @param a a positive integer
 * @param b a positive integer
 * @return a list of common factors of 'a' and 'b'
 *
 * Example:
 * findCommonFactors(12, 18)
 * Expected Output: [1, 2, 3, 6]
 */
fun findCommonFactors(a: Int, b: Int): List<Int> {

    val commonFactors = mutableListOf<Int>()

    // Iterate from 1 to the minimum of 'a' and 'b'
    for (i in 1..minOf(a, b)) {
        // Check if 'i' is a factor of both 'a' and 'b'
        if (a % i == 0 && b % i == 0) {
            commonFactors.add(i)
        }
    }

    return commonFactors
}