Problem

Source: Bulgarian NMO 2017, 3rd round, p2

Tags: number theory, combinatorics



Let $m>1$ be a natural number and $N=m^{2017}+1$. On a blackboard, left to right, are written the following numbers: \[N, N-m, N-2m,\dots, 2m+1,m+1, 1.\]On each move, we erase the most left number, written on the board, and all its divisors (if any). This procces continues till all numbers are deleted. Which numbers will be deleted on the last move.