Problem

Source: Baltic Way 2015

Tags: number theory



For any integer $n \ge2$, we define $ A_n$ to be the number of positive integers $ m$ with the following property: the distance from $n$ to the nearest multiple of $m$ is equal to the distance from $n^3$ to the nearest multiple of $ m$. Find all integers $n \ge 2 $ for which $ A_n$ is odd. (Note: The distance between two integers $ a$ and $b$ is defined as $|a -b|$.)