A natural number n represents the initial position in the game. When it is a players turn he/she is allowed to I)  Subtract 2 from nII) Subtract 3 from nIII)    Subtract 5 from nWe call the player who begin the game Adam and the other player Berta. The players alternate by applying on of the three rules to the number 0 or a negative number his/her opponent. If a player manages to produce the number 0 or a negative number he/she wins the game.Here is an example of a game played by Adam and Berta (for n=15)15 is given to Adam. He decides to subtract 5 leaving 15-5 = 10 to Berta10 is given to Berta. She decides to subtract 3 leaving 11-3=8 to Beta8 is given to Adam. He decides to subtract 2 leaving 8-2=6 to Berta6 is given to Berta. She decides to subtract 2 leaving 6-2=4 to Adam4 is given to Adam. He decides to subtract 5 producing -1 a negative number, Adam wins!b) we define a one dimensional array X(1), X(2),X(3),..,X(n)i)  X(j) =1 if Adam has a method to win when given the number jii) X(j)=0 if Adam has no method that guarantees that he wins when the given the number kCalculate X(1),X(2),X(3).,X(23),X(25)What is X(8), X(13) and X(24)?     Answer should be of the formboolean boolean boolean  so if X(8)=0 , X(13)=1 and X(24)=1 the correct answer is 011Thus the correct answer is one of the following 000 001 010 011 100 101 110 111My attempt is n=8Adam: 8-5=3Berta: 3-3 =0Berta wins  0n=13 Adam=13-5=8Berta: 8-3=5Adam 5- 5Adam wins 1I get really stuck with 24, so far I have 01 Is there a method for this type of problem, i have been stuck on it for ages now. Thanks in advance
Applying dynamic programming to a simple two-person game of perfect information
algorithms;complexity theory