ETS Interview Question

I was asked to write code to solve a simple numerical problem.