Nim Game


@yake For example, the binary presentation of 4 is 100, 8 is 1000..., which means the last two bits is always 0 if the number is 4's multiples. So n & 3 (n & 11) is for checking if the number is 4's multiples, and that is the result, too.

@yake: Compiler will probably optimize that anyway. In that case, I rather use the remainder which would be more clear.

@bdsh_14 In this question, both of you and your friend are very clever and have optimal strategies for the game. So if you pick 3, the opponent will pick 2 then you will lose.