Toptal Interview Question

Mathematics problem