AMD Interview Question

Coming up with an algorithm.