Amazon Interview Question

Math flow problem..