Bloomberg Interview Question

Most questions required a recursive approach