UVA 10404 Bachet's Game

I am not able to figure to what logic can be in this question, please explain the recursive approach. thanks :slight_smile:

Bachet’s Game