Just one line code can solve this problem.

```
return !(n%4==0);
```

First step try to make the total amount to be a multiple of 4, and no matter how many stones your opponent takes, just make the total to be a multiple of 4. Finally there will be 4 stones, and obviously you will win at the time.

This problem is a math trick game rather than an algorithm problem.