/**
 * This function takes two numbers a and b as input and returns a list of common factors of a and b.
 *
 * Example:
 * findCommonFactors(24, 36) should return [1, 2, 3, 4, 6, 12] since the common factors of 24 and 36 are 1, 2, 3, 4, 6, and 12.
 */
fun findCommonFactors(a: Int, b: Int): List<Int> {

    if (a !is Int || b !is Int) {
        return listOf()
    }

    // find factors of a
    val factorsA = mutableListOf<Int>()
    for (i in 1..Math.abs(a)) {
        if (a % i == 0) {
            factorsA.add(i)
        }
    }

    // find factors of b
    val factorsB = mutableListOf<Int>()
    for (j in 1..Math.abs(b)) {
        if (b % j == 0) {
            factorsB.add(j)
        }
    }

    // find common factors
    val commonFactors = factorsA.filter { it in factorsB }

    return commonFactors
}
/**
 * This function takes two numbers a and b as input and returns a list of common factors of a and b.
 *
 * Example:
 * findCommonFactors(24, 36) should return [1, 2, 3, 4, 6, 12] since the common factors of 24 and 36 are 1, 2, 3, 4, 6, and 12.
 */
fun findCommonFactors(a: Int, b: Int): List<Int> {
/**
 * This function takes two numbers a and b as input and returns a list of common factors of a and b.
 *
 * Example:
 * findCommonFactors(24, 36) should return [1, 2, 3, 4, 6, 12] since the common factors of 24 and 36 are 1, 2, 3, 4, 6, and 12.
 */
fun findCommonFactors(a: Int, b: Int): List<Int> {

    if (a !is Int || b !is Int) {
        return listOf()
    }

    // find factors of a
    val factorsA = mutableListOf<Int>()
    for (i in 1..Math.abs(a)) {
        if (a % i == 0) {
            factorsA.add(i)
        }
    }

    // find factors of b
    val factorsB = mutableListOf<Int>()
    for (j in 1..Math.abs(b)) {
        if (b % j == 0) {
            factorsB.add(j)
        }
    }

    // find common factors
    val commonFactors = factorsA.filter { it in factorsB }

    return commonFactors
}