Answer: f(n)=n for all n∈N.
Taking m=n=1 in (∗) yields 1+f(1)!∣f(1)!+f(1) and hence 1+f(1)!∣f(1)−1. Since ∣f(1)−1∣<f(1)!+1, this implies f(1)=1.
For m=1 in (∗) we have n!+1∣f(n)!+1, which implies n!⩽f(n), i.e. f(n)⩾n.
On the other hand, taking (m,n)=(1,p−1) for any prime number p and using Wilson's theorem we obtain p∣(p−1)!+1∣f(p−1)!+1, implying f(p−1)<p. Therefore
f(p−1)=p−1
Next, fix a positive integer m. For any prime number p, setting n=p−1 in (*) yields (p−1)!+f(m)!∣(p−1)!+f(m!), and hence
(p−1)!+f(m)!∣f(m!)−f(m)! for all prime numbers p
This implies f(m!)=f(m)! for all m∈N, so (∗) can be rewritten as n!+f(m)!∣f(n)!+f(m)!. This implies
n!+f(m)!∣f(n)!−n! for all n,m∈N
Fixing n∈N and taking m∈N large enough, we conclude that f(n)!=n!, i.e. f(n)=n, for all n∈N.
One readily checks that the identity function satisfies the conditions of the problem.