/**
 * Given two lists, this function finds the common elements that appear in both lists.
 *
 * @param list1 the first list
 * @param list2 the second list
 * @return a new list containing the common elements found in both lists
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) should return listOf(3, 4)
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Loop through the first list
    for (element in list1) {
        // Check if the element is in the second list
        if (element in list2) {
            // If it is, add it to the commonElements list
            commonElements.add(element)
        }
    }

    return commonElements
}
/**
 * Given two lists, this function finds the common elements that appear in both lists.
 *
 * @param list1 the first list
 * @param list2 the second list
 * @return a new list containing the common elements found in both lists
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) should return listOf(3, 4)
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * Given two lists, this function finds the common elements that appear in both lists.
 *
 * @param list1 the first list
 * @param list2 the second list
 * @return a new list containing the common elements found in both lists
 *
 * Example:
 * findCommonElements(listOf(1, 2, 3, 4), listOf(3, 4, 5, 6)) should return listOf(3, 4)
 */
fun findCommonElements(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonElements = mutableListOf<Int>()

    // Loop through the first list
    for (element in list1) {
        // Check if the element is in the second list
        if (element in list2) {
            // If it is, add it to the commonElements list
            commonElements.add(element)
        }
    }

    return commonElements
}