ETS interview question

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