Microsoft interview question

Quick sort, and a riddle that could be easily solved using maths.