Isaac Emmanuel
09 Sept 2026•EasyGo / Python / TypeScript

Divisor Game

Determine whether the first player can force a win in the divisor subtraction game.

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
package main

func divisorGame(n int) bool { return n%2 == 0 }
Python•divisor-game/solution.py
class Solution:
    def divisorGame(self, n: int) -> bool:
        return n % 2 == 0
TypeScript•divisor-game/solution.ts
function divisorGame(n: number): boolean {
  return n % 2 === 0;
}