/**
 * This function takes a list of positive integers and a check number as input. It determines whether the check number 
 * is a member of the list of positive integers.
 *
 * @param numbers A list of positive integers.
 * @param checkNumber An integer to check membership in the list.
 * @return True if the check number is a member of the list, False otherwise.
 */
fun positiveIntegerMembership(numbers: List<Int>, checkNumber: Int): Boolean {

    // Sort the list in ascending order
    val sortedNumbers = numbers.sorted()

    // Initialize the start and end indices for binary search
    var startIndex = 0
    var endIndex = sortedNumbers.size - 1

    // Perform binary search until start index crosses end index
    while (startIndex <= endIndex) {
        val midIndex = (startIndex + endIndex) / 2

        // If the middle element equals the check number, return True
        if (sortedNumbers[midIndex] == checkNumber) {
            return true
        }

        // If the middle element is less than the check number, search in the right half of the list
        else if (sortedNumbers[midIndex] < checkNumber) {
            startIndex = midIndex + 1
        }

        // If the middle element is greater than the check number, search in the left half of the list
        else {
            endIndex = midIndex - 1
        }
    }

    return false
}
/**
 * This function takes a list of positive integers and a check number as input. It determines whether the check number 
 * is a member of the list of positive integers.
 *
 * @param numbers A list of positive integers.
 * @param checkNumber An integer to check membership in the list.
 * @return True if the check number is a member of the list, False otherwise.
 */
fun positiveIntegerMembership(numbers: List<Int>, checkNumber: Int): Boolean {
/**
 * This function takes a list of positive integers and a check number as input. It determines whether the check number 
 * is a member of the list of positive integers.
 *
 * @param numbers A list of positive integers.
 * @param checkNumber An integer to check membership in the list.
 * @return True if the check number is a member of the list, False otherwise.
 */
fun positiveIntegerMembership(numbers: List<Int>, checkNumber: Int): Boolean {

    // Sort the list in ascending order
    val sortedNumbers = numbers.sorted()

    // Initialize the start and end indices for binary search
    var startIndex = 0
    var endIndex = sortedNumbers.size - 1

    // Perform binary search until start index crosses end index
    while (startIndex <= endIndex) {
        val midIndex = (startIndex + endIndex) / 2

        // If the middle element equals the check number, return True
        if (sortedNumbers[midIndex] == checkNumber) {
            return true
        }

        // If the middle element is less than the check number, search in the right half of the list
        else if (sortedNumbers[midIndex] < checkNumber) {
            startIndex = midIndex + 1
        }

        // If the middle element is greater than the check number, search in the left half of the list
        else {
            endIndex = midIndex - 1
        }
    }

    return false
}