Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Divisor Game

XPChallenge Points: 10
levelLevel: Easy

Alice and Bob are playing a mathematical game using a single integer, n, written on the chalkboard.
Alice always moves first, and both play optimally.
On each player’s turn:
1. The player chooses an integer x such that 0 < x < n and n % x == 0.
2. The number on the board is replaced with n - x.
If a player cannot make any valid move, that player loses the game.
Your task is to return:
• true → if Alice wins the game,
• false → if Bob wins the game.
________________________________________
⚙️ Rules Summary
• Each move must choose a divisor of the current number.
• The game ends when no valid divisor x can be chosen.
• Both players aim to win — they play optimally.

Example 1:

Input: n = 4

Output: true

Example 2:

Input: n = 7

Output: false

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result