An even starting value always moves to an odd one, while every legal move from an odd value reaches an even one; therefore the first player wins exactly for even n.
complexity
O(1) time and O(1) space.
solution files
- Go
divisor-game/solution.go - Python
divisor-game/solution.py - TypeScript
divisor-game/solution.ts