Function with $f(a)-f(b)$ dividing $a^3-b^3$ What are all functions $f:\mathbb{Z}\rightarrow\mathbb{Z}$ such that $f(a)-f(b)$ divides $a^3-b^3$ for all $a,b\in\mathbb{Z}$ such that $f(a)\neq f(b)$?
The constant functions satisfy vacuously, and both $f(x)=x+c$ and $f(x)=-x+c$ works for any $c\in\mathbb{Z}$. Same with $f(x)=x^3+c$ and $f(x)=-x^3+c$. Are there other such functions?
Edit: As Meelo pointed out, any function with range spanning only two consecutive integers works, since $\pm1$ divides everything.
 A: What about $f(x)=x^3$?
${}{}{}{}{}{}{}{}{}{}{}{}{}$
A: Some partial results.
We may assume $f(0) = 0$: any other solution can be obtained from a solution of this form by adding a constant.
This implies, for all $n$, either $f(n) = 0$ or $f(n) \mid n^3$.
Lemma: Suppose that $f(n) \notin \{ -1, 0, 1 \}$ and $\gcd(m,n) = 1$. Then $f(m) \neq 0$
Proof: Suppose otherwise. Then $f(n) \mid n^3 - m^3$, which implies $f(n) \mid m^3$. Because $\gcd(m,n)=1$ and $f(n) \mid n^3$, this implies $f(n) = \pm 1$, contradicting our hypothesis. $\square$
If $f$ has any values other than $-1, 0, 1$, then that implies $f(1) = \pm 1$. We may assume $f(1) = 1$: any other solution can be obtained from this by multiplying $f$ by $-1$. (I, of course, continue to assume $f(0) = 0$)
Lemma: If $f(1) = 1$, then for every positive prime number, $f(p) \in \{ -1, 0, 1, p, p^3 \}$.
Proof: If $f(p) \neq 0$, then we have $f(p) - 1 \mid p^3 - 1$ and $f(p) \mid p^3$. Exhaustively checking all 8 possibilities for $f(p)$ reveals that only the four listed above work. For example, $$\gcd(-p^2 - 1, p^3 - 1) = \gcd(-p^2 - 1, -p-1) \neq p^2 + 1$$ and so we can't have $f(p) = -p^2$. $\square$
