Let the set of all positive divisors of n be A, and let the set of numbers in 1,2,⋯,n that are coprime with n be B. Since there is exactly one number 1∈A∩B in 1,2,⋯,n, we have
d(n)+φ(n)⩽n+1.
Thus, c=0 or 1.
(1) When c=0, from d(n)+φ(n)=n, we know that there is exactly one number in 1,2,⋯,n that does not belong to A∪B. If n is even and n>8, then n−2,n−4 do not belong to A∪B, so n does not satisfy the equation. If n is odd, when n is a prime or 1, d(n)+φ(n)=n+1 (which falls under case (2)); when n is a composite number, let n=pq,1<p⩽q,p,q are both odd numbers. If q⩾5, then 2p,4p do not belong to A∪B, so n does not satisfy the equation.
In summary, only when n⩽8,n is even, or n⩽9,n is an odd composite number, does
d(n)+φ(n)=n.
Direct verification shows that n can only be 6,8,9.
(2) When c=1, from d(n)+φ(n)=n+1, we know that every number in 1,2,⋯,n belongs to A∪B. It is easy to see that, in this case, n=1 or a prime number meets the requirement. For the case when n is even, as discussed above, if n is even, then n⩽4 (consider the number n−2); if n is an odd composite number, let n=pq,3⩽p⩽q,p,q are both odd numbers, in this case, 2p does not belong to A∪B, which is a contradiction.
Direct verification shows that n=4 meets the requirement.
Therefore, the n that satisfies d(n)+φ(n)=n+1 is 1, 4, or a prime number.