Amazon Interview Question

First was the numerical test