Let f:Z→Z satisfy the given functional equation. Putting n=0 in this equation, we get
f(2m+f(m)+f(m)f(0))=m∀m∈Z;
therefore, f is surjective, so there exists u∈Z such that f(u)=−1.
With m=u, the given equation gives us
f(2u−1−f(n))=−n+u.
Now, if a,b are some integers such that f(a)=f(b), then
u−a=f(2u−1−f(a))=f(2u−1−f(b))=u−b,
which implies that a=b. Hence, f is also injective.
Next, putting n=u, we have
f(2m+f(m)−f(m))=uf(m)+m⇔f(2m)=uf(m)+m(∗)
for all m∈Z. In ( ∗ ), letting m=0, we see that f(0)=uf(0), so u=1 or f(0)=0.
If f(0)=0, then with m=u, (*) would imply f(2u)=−u+u=0=f(0), i.e. 2u=0⇔u=0 (since f is injective), and thus f(0)=−1, a contradiction!
Hence, u=1⇔f(1)=−1 and ( ∗ ) becomes
f(2m)=f(m)+m
for all m∈Z. Here, letting m=1, we obtain f(2)=0.
In the given functional equation, putting m=n=0, we have
f(f(0)+f(0)2)=0⇔f(0)+f(0)2=2⇔f(0)=1 or f(0)=−2.
If f(0)=1, then it would follow from the given equation with m=0,n=2 that f(1)=2, a contradiction (because f(1)=−1 )!
Hence, f(0)=−2. In the functional equation, putting n=0, we get
f(2m−f(m))=m∀m∈Z
Using this, we see that if f(m)=m−2 then f(m+2)=m; but f(0)=−2,f(1)=−1, we can easily prove by induction that f(n)=n−2 for all n≥0.
In the given equation, letting m=1, we obtain
f(2−1−f(n))=−n+1⇔f(1−f(n))=1−n∀n∈Z.
Now replacing n by n+3 and letting n≥−3, we have
f(1−f(n+3))=−n−2⇔f(1−(n+1))=−n−2⇔f(−n)=−n−2.
So f(n)=n−2 for all n∈Z.
It is easy to check that this function satisfies the given condition.