Find winner of the Game of Nim
Submissions: 2194   Accuracy:


  Difficulty: Easy   Marks: 2

In Game of Nim, two players take turns removing objects from heaps or the pile of stones.
Suppose two players A and B are playing the game. Each is allowed to take only one stone from the pile. The player who picks the last stone of the pile will win the game. Given N the number of stones in the pile, the task is to find the winner, if player A starts the game .

The input line contains T, denoting the number of test cases. Then T test case follows, a single line of the input containing a positive integer N.

Print the winner i.e. Player A or Player B for each testcase in a separate line.

1 <= T <= 100
1 <= N <= 1000



Player A

Player A

Testcase 1: Player A remove stone 1 which is at the top, then Player B remove stone 2
and finally player A removes the last stone.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sahil Chhabra
Author: Sahil_Chhabra

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.