/**
 * The function takes two sets as input and finds the common elements between them.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements between set1 and set2.
 */
fun findCommonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    val commonElements = mutableSetOf<Int>()  // Create an empty set to store common elements

    // Nested loop to iterate over each element in set1 and set2
    for (element1 in set1) {
        for (element2 in set2) {
            if (element1 == element2) {
                commonElements.add(element1)  // Add common element to the set
            }
        }
    }

    return commonElements
}

// Uncomment the following lines to test the function

// val set1 = setOf(1, 2, 3, 4, 5)
// val set2 = setOf(3, 4, 5, 6, 7)
// println(findCommonElements(set1, set2))
// Output: [3, 4, 5]
/**
 * The function takes two sets as input and finds the common elements between them.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements between set1 and set2.
 */
fun findCommonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {
/**
 * The function takes two sets as input and finds the common elements between them.
 *
 * @param set1 The first set.
 * @param set2 The second set.
 * @return A set containing the common elements between set1 and set2.
 */
fun findCommonElements(set1: Set<Int>, set2: Set<Int>): Set<Int> {

    val commonElements = mutableSetOf<Int>()  // Create an empty set to store common elements

    // Nested loop to iterate over each element in set1 and set2
    for (element1 in set1) {
        for (element2 in set2) {
            if (element1 == element2) {
                commonElements.add(element1)  // Add common element to the set
            }
        }
    }

    return commonElements
}

// Uncomment the following lines to test the function

// val set1 = setOf(1, 2, 3, 4, 5)
// val set2 = setOf(3, 4, 5, 6, 7)
// println(findCommonElements(set1, set2))
// Output: [3, 4, 5]