/**
 * In this exercise, you are given two lists containing integers. Your task is to write a function that finds the common 
 * numbers in both lists and returns them as a new list. The function should consider nested loops and the use of the OR operator.
 * 
 * @param list1 A list of integers
 * @param list2 A list of integers
 * @return A list containing the common numbers in both lists, without duplicates
 * 
 * Example:
 * findCommonNumbers(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonNumbers(listOf(-1, 0, 1, 2), listOf(2, 3, 4, 5)) // [2]
 */
fun findCommonNumbers(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonNumbers = mutableListOf<Int>()
    for (num1 in list1) {
        for (num2 in list2) {
            if (num1 == num2 && num1 !in commonNumbers) { // use of nested loops and avoiding duplicate numbers
                commonNumbers.add(num1)
            }
        }
    }
    return commonNumbers
}
/**
 * In this exercise, you are given two lists containing integers. Your task is to write a function that finds the common 
 * numbers in both lists and returns them as a new list. The function should consider nested loops and the use of the OR operator.
 * 
 * @param list1 A list of integers
 * @param list2 A list of integers
 * @return A list containing the common numbers in both lists, without duplicates
 * 
 * Example:
 * findCommonNumbers(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonNumbers(listOf(-1, 0, 1, 2), listOf(2, 3, 4, 5)) // [2]
 */
fun findCommonNumbers(list1: List<Int>, list2: List<Int>): List<Int> {
/**
 * In this exercise, you are given two lists containing integers. Your task is to write a function that finds the common 
 * numbers in both lists and returns them as a new list. The function should consider nested loops and the use of the OR operator.
 * 
 * @param list1 A list of integers
 * @param list2 A list of integers
 * @return A list containing the common numbers in both lists, without duplicates
 * 
 * Example:
 * findCommonNumbers(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * findCommonNumbers(listOf(-1, 0, 1, 2), listOf(2, 3, 4, 5)) // [2]
 */
fun findCommonNumbers(list1: List<Int>, list2: List<Int>): List<Int> {

    val commonNumbers = mutableListOf<Int>()
    for (num1 in list1) {
        for (num2 in list2) {
            if (num1 == num2 && num1 !in commonNumbers) { // use of nested loops and avoiding duplicate numbers
                commonNumbers.add(num1)
            }
        }
    }
    return commonNumbers
}