****** Welcome to the game of Nim ****** The number of marbles you draw must be > 0 and <= half of the total marbles. The person who gets the last marble loses. You go first. Initial number of marbles: 15 The computer is playing stupid. Enter number of marble(s) to draw: 6 Current number of marble(s): 9 Computer takes off 2 marble(s). Current number of marble(s): 7 Enter number of marble(s) to draw: 3 Current number of marble(s): 4 Computer takes off 2 marble(s). Current number of marble(s): 2 Enter number of marble(s) to draw: 2 Enter number of marble(s) to draw: 1 Current number of marble(s): 1 You win!Here is a sample run when the computer plays smart:
****** Welcome to the game of Nim ****** The number of marbles you draw must be > 0 and <= half of the total marbles. The person who gets the last marble loses. You go first. Initial number of marbles: 98 The computer is playing smart. Enter number of marble(s) to draw: 1 Current number of marble(s): 97 Computer takes off 34 marble(s). Current number of marble(s): 63 Enter number of marble(s) to draw: 2 Current number of marble(s): 61 Computer takes off 30 marble(s). Current number of marble(s): 31 Enter number of marble(s) to draw: 3 Current number of marble(s): 28 Computer takes off 13 marble(s). Current number of marble(s): 15 Enter number of marble(s) to draw: 4 Current number of marble(s): 11 Computer takes off 4 marble(s). Current number of marble(s): 7 Enter number of marble(s) to draw: 3 Current number of marble(s): 4 Computer takes off 1 marble(s). Current number of marble(s): 3 Enter number of marble(s) to draw: 2 Enter number of marble(s) to draw: 1 Current number of marble(s): 2 Computer takes off 1 marble(s). Current number of marble(s): 1 The computer wins!The format of the output is not important, but make sure you include the key elements. Now that you have enough information, get started on this program. As usual, refer to my solution only when you’ve racked your brain and still cannot finish the program.