Game of sum (Uva)

Unable to come up with the logic any one please help me?Thank u :slight_smile:
link:link text

link 1

link 2