Nim Game

Easy · Math & Number Theory · about 5 minutes

Asked at Google, Amazon, Adobe, Microsoft.

There is a heap of n stones. You and a friend alternate turns, you first; each turn removes 1 to 3 stones, and whoever removes the last stone wins. Both play optimally. Return true if you can win.