Amazon interview question

Trying to answer the math question in a reasonable time