function a = find(nums, num)
    middle = floor(size(nums, 2)/2);
    low = 1;
    hi = size(nums, 2);
    
    while nums(middle) ~= num
        if nums(middle) > num
            hi = middle - 1;
        else
            low = middle + 1; 
        end
        
        if low > hi
            a = -1
            return
        end
        
        middle = floor((hi - low)/2) + low;
    end
    
    a = middle
end