input: Write a function to implement binary search.
  assert binarySearch([2, 3, 4, 5, 6, 7, 8], 6) == 4
  assert binarySearch([2, 3, 4, 5, 6, 7, 8], 3) == 1
  assert binarySearch([2, 3, 4, 5, 6, 7, 8], 9) == None
  assert binarySearch([1, 2, 3, 4, 5], 1) == 0
output: def binarySearch(arr, x):
      left, right = 0, len(arr) - 1
      while left <= right:
          mid = (left + right) // 2
          if arr[mid] == x:
              return mid
          elif arr[mid] < x:
              left = mid + 1
          else:
              right = mid - 1
      return None