Problem

Source: 2019 Belarus Team Selection Test 8.2

Tags: algebra, functional equation, function



Let $\mathbb Z$ be the set of all integers. Find all functions $f:\mathbb Z\to\mathbb Z$ satisfying the following conditions: 1. $f(f(x))=xf(x)-x^2+2$ for all $x\in\mathbb Z$; 2. $f$ takes all integer values. (I. Voronovich)