Problem

Source: Baltic Way 2020, Problem 18

Tags: number theory, number theory proposed, AZE CMO TST, AZE EGMO TST



Let $n\geq 1$ be a positive integer. We say that an integer $k$ is a fan of $n$ if $0\leq k\leq n-1$ and there exist integers $x,y,z\in\mathbb{Z}$ such that \begin{align*} x^2+y^2+z^2 &\equiv 0 \pmod n;\\ xyz &\equiv k \pmod n. \end{align*}Let $f(n)$ be the number of fans of $n$. Determine $f(2020)$.