Problem

Source: All Russian Olympiad 2015 11.2

Tags: number theory



Let $n > 1$ be a natural number. We write out the fractions $\frac{1}{n}$, $\frac{2}{n}$, $\dots$ , $\dfrac{n-1}{n}$ such that they are all in their simplest form. Let the sum of the numerators be $f(n)$. For what $n>1$ is one of $f(n)$ and $f(2015n)$ odd, but the other is even?