Bloomberg interview question

Most questions required a recursive approach