I was searching for a visualization that explained this algorithm but I found more. I didn't know about the problem in line 5. Thank you for sharing!! I am not a computer scientist but I find this phenomenon fantastic. Both expressions are mathematically equivalent but when applying to a computer things change. Excellent!!! In en.wikipedia.org/wiki/Binary_search > Implementation issues, this aspect is mention but I didn't spot it at first glance.