Toptal interview question

Mathematics problem