Bloomberg Interview Question

was given a question to solve on hackerrank collab edit. It was a medium level leetcode problem involving math.