def binary_search(array, x):
    """Find the position of a target value, x, in a sorted array. Time
    complexity of O(log n).

    Parameters
    ----------
    array : iterable
        A list of sorted numbers
    x : int
        The number to be searched for
    """
    lower_bound = 0
    upper_bound = len(array) - 1
    while True:
        mid = int((lower_bound + upper_bound) / 2)
        if x == array[mid]:
            print("A student aged", x, "was found.")
            return 0
        elif lower_bound > upper_bound:
            print("A student aged", x, "was not found.")
            return -1
        else:
            if x < array[mid]:
                upper_bound = mid - 1
            else:
                lower_bound = mid + 1