Let ℓ be a positive integer. By substituting (m,n)=(f(ℓ),ℓ) and (ℓ,f(ℓ)) into the original equation and comparing them, we obtain
ff(ℓ)+1(ℓ)+ℓf(ℓ)=f(ℓ)f(f(ℓ))=ff(f(ℓ))(ℓ)+ℓf(ℓ),
or ff(ℓ)+1(ℓ)=ff(f(ℓ))(ℓ).
Letting m=n in the original equation yield f(n)2=n2+ff(n)(n)>n2, or f(n)>n. Hence, fk+1(n)=f(fk(n))>fk(n) for any positive integer k, which leads to
f(n)<f2(n)<f3(n)<…
In particular, if fs(n)=ft(n) for some positive integers s,t, then s=t. Combined with ff(ℓ)+1(ℓ)=ff(f(ℓ))(ℓ), we obtain f(f(ℓ))=f(ℓ)+1.
In particular, by letting k=f(n) in the above statement, ff(n)(n)=f(n)+f(n)−1=2f(n)−1. We also have f(n)2=n2+ff(n)(n) (see the second paragraph), and we deduce (f(n)−1)2=n2. Since f(n)−1≥0, it implies f(n)−1=n, or f(n)=n+1.
We conclude the proof by checking f(n)=n+1 satisfies the original equation. The left side of the equation is ff(n)(m)+mn=m+f(n)+mn=mn+m+n+1; the right is f(m)f(n)=(m+1)(n+1)=mn+m+n+1. Therefore, the answer is f(n)=n+1.