---
# System prepended metadata

title: \#292 Nim Game
tags: [leetcode, leetcode-easy]

---

# \#292 Nim Game
## *給定n為堆疊的牌張數, 兩人輪流拿1~3張, 拿最後一張牌的人輸(由你先拿), 回傳是否你會贏(假定兩人都想贏)*
## Log
 - build 20210610 by syhuang

## 數學歸納法
 - 數學歸納結論:當輪到某方拿牌時n為4的倍數, 則該方必定會輸
```javascript=
var canWinNim = function(n) {
    return !(n%4==0);
};
```
## 備註
 - 爛題目, 不過可複習高中數學歸納法
## 參考
 - [參考解](https://leetcode.com/problems/nim-game/discuss/73749/Theorem%3A-all-4s-shall-be-false)
###### tags: `leetcode`, `leetcode-easy`