Problem

Source: Peru Ibero+Cono Sur TST 2020 P2

Tags: number theory, functional equation



Find all functions $f : \mathbb{Z} \to \mathbb{Z}$ that satisfy the conditions: $i) f(f(x)) = xf(x) - x^2 + 2,\forall x\in\mathbb{Z}$ $ii) f$ takes all integer values