function binarySearch(arr, value)
local low = 1
local high = #arr
while low <= high do
local mid = math.floor((low + high) / 2)
if arr[mid] > value then high = mid - 1
elseif arr[mid] < value then low = mid + 1
else return mid
end
end
return false
end
arr = {2, 3, 4, 7, 9, 12, 14, 15, 18, 22}
print(binarySearch(arr, 9))
--[[
run:
5
--]]