AMD interview question

Coming up with an algorithm.