There is a unique solution: the function f:N→N defined by f(1)=1 and
f(n)=p1p1a1−1p2p2a2−1⋯pkpkak−1 where n=p1a1p2a2⋯pkak is the prime factorization of n>1.
Direct verification shows that this function meets the requirements.
Conversely, let f:N→N satisfy (i) and (ii). Applying (i) for x=1 gives d(f(1))=1, so f(1)=1. In the sequel we prove that (1) holds for all n>1. Notice that f(m)=f(n) implies m=n in view of (i). The formula d(p1b1⋯pkbk)=(b1+1)⋯(bk+1) will be used throughout.
Let p be a prime. Since d(f(p))=p, the formula just mentioned yields f(p)=qp−1 for some prime q; in particular f(2)=q2−1=q is a prime. We prove that f(p)=pp−1 for all primes p.
Suppose that p is odd and f(p)=qp−1 for a prime q. Applying (ii) first with x=2, y=p and then with x=p,y=2 shows that f(2p) divides both (2−1)p2p−1f(2)=p2p−1f(2) and (p−1)22p−1f(p)=(p−1)22p−1qp−1. If q=p then the odd prime p does not divide (p−1)22p−1qp−1, hence the greatest common divisor of p2p−1f(2) and (p−1)22p−1qp−1 is a divisor of f(2). Thus f(2p) divides f(2) which is a prime. As f(2p)>1, we obtain f(2p)=f(2) which is impossible. So q=p, i.e. f(p)=pp−1.
For p=2 the same argument with x=2,y=3 and x=3,y=2 shows that f(6) divides both 35f(2) and 26f(3)=2632. If the prime f(2) is odd then f(6) divides 32=9, so f(6)∈{1,3,9}. However then 6=d(f(6))∈{d(1),d(3),d(9)}={1,2,3} which is false. In conclusion f(2)=2.
Next, for each n>1 the prime divisors of f(n) are among the ones of n. Indeed, let p be the least prime divisor of n. Apply (ii) with x=p and y=n/p to obtain that f(n) divides (p−1)yn−1f(p)=(p−1)yn−1pp−1. Write f(n)=ℓP where ℓ is coprime to n and P is a product of primes dividing n. Since ℓ divides (p−1)yn−1pp−1 and is coprime to yn−1pp−1, it divides p−1; hence d(ℓ)≤ℓ<p. But (i) gives n=d(f(n))=d(ℓP), and d(ℓP)=d(ℓ)d(P) as ℓ and P are coprime. Therefore d(ℓ) is a divisor of n less than p, meaning that ℓ=1 and proving the claim.
Now (1) is immediate for prime powers. If p is a prime and a≥1, by the above the only prime factor of f(pa) is p (a prime factor does exist as f(pa)>1). So f(pa)=pb for some b≥1, and (i) yields pa=d(f(pa))=d(pb)=b+1. Hence f(pa)=ppa−1, as needed.
Let us finally show that (1) is true for a general n>1 with prime factorization n=p1a1⋯pkak. We saw that the prime factorization of f(n) has the form f(n)=p1b1⋯pkbk. For i=1,…,k, set x=piai and y=n/x in (ii) to infer that f(n) divides (piai−1)yn−1f(piai). Hence pibi divides (piai−1)yn−1f(piai), and because pibi is coprime to (piai−1)yn−1, it follows that pibi divides f(piai)=pipiai−1. So bi≤piai−1 for all i=1,…,k. Combined with (i), these conclusions imply
p1a1⋯pkak=n=d(f(n))=d(p1b1⋯pkbk)=(b1+1)⋯(bk+1)≤p1a1⋯pkak
Hence all inequalities bi≤piai−1 must be equalities, i=1,…,k, implying that (1) holds true. The proof is complete.