The sought functions are those of the form f(n)=c⋅νp(n), where p is some prime, c is a positive integer, and νp(n) denotes the exponent of p in the prime decomposition of n.
Solution 1. If a number n is a product of primes, n=p1p2⋯pk, then
f(n)=f(p1)+f(p2)+⋯+f(pk),
in particular, f(1)=0 (since f(1)=f(1)+f(1)).
It is also clear that f(n)=0 implies f(p)=0 for all primes p dividing n.
Let us call a positive integer n good if f(k)=f(n−k) for 0<k<n. If n is good then each its divisor d is also good; indeed, if n=dm, then
f(k)=f(mk)−f(m)=f(n−mk)−f(m)=f(m(d−k))−f(m)=f(d−k)
for 0<k<d. Thus, good numbers are products of good primes.
It follows immediately from (1) that there exists a prime p such that f(p)=0; let p be the smallest such prime. Then f(r)=0 for all r<p (since all prime divisors of r<p are less than p). Now every good number n>p must be divisible by p. Indeed, if n=pk+r is a good number, k>0, 0<r<p, then f(p)≤f(pk)=f(n−pk)=f(r)=0, a contradiction. Since any divisor of a good number is also good, this means that if a divisor r of a good number is not divisible by p, it is less than p. Thus all good numbers have the form r⋅pk with r<p. The condition (3) implies that k can be arbitrarily large, consequently all powers of p are good.
If q=p is a prime, pq−1−1 is divisible by q and pq−1 is good. Then f(q)≤f(pq−1−1)=f(1)=0, that is, f(q)=0.
Now, we see that f(n)=νp(n)⋅c, where c=f(p). The conditions (1) and (2) for all such functions with c=0 are obvious; the condition (3) holds for all n=pm, since νp(pm−k)=νp(k) when 0<k<pm.
Solution 2. We use the notion of a good number from the previous solution. As above, we also denote by νp(n) the exponent of a prime p in the prime decomposition of n.
Say that a positive integer k is big if f(k)>0. Let B be the set of big primes, and let p1<p2<… list the elements of B (this set might be either finite or infinite). By the problem conditions, we have
f(n)=i∑νpi(n)f(pi);(B1)
thus, the big numbers are those divisible by at least one big prime.
For a positive integer k, define its essence e(k) to be the largest product e of (not necessarily different) big primes such that e∣k. In other words,
e(n)=pi∈B∏piνpi(n).
This yields that k/e(k) is not big, so f(k)=f(e(k))+f(k/e(k))=f(e(k)).
Lemma. Assume that n is a good number. Then e(k)=e(n−k) for all 0<k<n.
Proof. Arguing indirectly, choose a minimal k for which the claim of the lemma is violated. Clearly, k is big, as otherwise f(k)=f(n−k)=0 and hence e(k)=e(n−k)=1.
There are t=k/e(k) multiples of e(k) in each of the segments [1,k] and [n−k,n−1]. On the other hand, there are t−1 such multiples on [1,k−1] — and, by minimality of k, on [n−k+1,n−1] as well. This yields that n−k is a multiple of e(k). Therefore,
f(e(k))=f(k)=f(n−k)=f(e(k))+f(e(k)n−k),
so the last summand vanishes, hence e(k)n−k has no big prime divisors, that is, e(n−k)=e(k). This contradicts to our choice. □
Back to the problem, assume that ∣B∣≥2. Take any good number n>p1p2, and let p1α be the largest power of p1 smaller than n, so that n≤p1α+1<p1αp2. By the lemma, e(n−p1α)=e(p1α)=p1α, which yields p1α∣n. Similarly, p2∣n, so that n≥p1αp2. This contradiction shows that ∣B∣≤1, which by (B1) yields that f is listed in the answer.
Solution 3. We have f(∏piαi)=∑αif(pi). Note that
f(n−1)+f(n−2)+⋯+f(n−k)≥f(1)+f(2)+…f(k)
for all k=1,2,…,n−1, since the difference LHS - RHS is just f((kn−1)). Assume that f(p)>0. If f(k)=f(n−k) for all k, it implies that (kn−1) is not divisible by p for k=1,2,…,n−2. It is well known that it implies n=a⋅ps, a<p. If there are two primes p,q such that f(p)>0, f(q)>0, there exist only finitely many n which are equal both to a⋅ps, a<p, and b⋅qt, b<q. So there exists at most one such p, and therefore f(n)=C⋅νp(n) for some constant C.
Solution 4. We call a function f:N→N0 satisfying (2) additive. We call a pair (f,n), where f is an additive function and n∈N, good, if for all k<n it holds f(k)=f(n−k). For an additive function f and a prime number p the number lnpf(p) is denoted by g(f,p).
Let (f,n) be a good pair such that f(p)>0 for at least two primes less than n. Let p0 be the prime with maximal g(f,p) among all primes p<n. Let a0 be the maximal exponent such that p0a0<n. Then f(k)<f(p0a0) for all k<p0a0. Indeed, if k=p1a1⋯pmam<p0a0, then
f(k)=a1f(p1)+⋯+amf(pm)=g(f,p1)a1lnp1+⋯+g(f,pm)amlnam<g(f,p0)a0lnp0=f(p0a0).
Let n=bp0a0+r, where 0<r<p0a0. Then f(r)=f(bp0a0)≥f(p0a0). This contradiction shows that p0a0∣n. Then n=p0νp0(n)n′, where n′≤p0.
The function f1(m):=f(p0)νp0(m) and f2:=f−f1 are additive (obviously f(m)≥f(p0νp0(m))=f1(m), since p0νp0(m) divides m). For k<n, νp(k)=νp(n−k). Hence the pair (f2,n) is also good. Note that f2(p0)=0.
Choose among all primes p<n the prime q0 with maximal g(f2,p). As above we can prove that n=q0νq0(n)n′′ with n′′<q0. Since p0=q0, we get a contradiction. Thus f(n)=f(p)⋅νp(n).