Amazon Interview Question

Math flow problem was altered as your briefed your solution.