P(x)=x or P(x)=c, where c∈{1,…,9}
Suppose P(x)=adxd+⋯+a1x1+a0. Consider n=9×10k, where k is a sufficiently large positive integer; note that S(n)=9⇒P(S(n))=P(9).
1. We first prove that all coefficients are nonnegative.
Suppose there exists 0≤i<d such that ai<0, then it is easy to see that the digits of P(n) corresponding to 10ik+m+1 through 10(i+1)k−1 are all 9, so S(P(n))≥9(k−m−1). Taking k sufficiently large, then 9(k−m−1)>P(9)=P(S(n)), so S(P(n))=P(S(n)), a contradiction.
2. Next we prove that deg(P(x))≤1.
Since all coefficients are nonnegative, when k is sufficiently large, P(n) will consist of ad×9d,ad−1×9d−1,…,a0 with some 0's inserted in between, that is,
S(P(n))=S(ad×9d)+⋯+S(a0).
Also S(P(n))=P(S(n))=P(9), so we have
S(ad×9d)+⋯+S(a0)=P(9)=ad×9d+⋯+a0.(1)
However, for all positive integers m, it is clear that S(m)≤m, with equality holding only when m∈{1,…,9}, so ∀i≥2,ai=0.
3. (1) also tells us that a1≤1 and a0≤9.
- If a1=1 and a0≥1, take n=10k+(10−a0), we get
S(P(n))=S(10k+10)=2=11=P(11−a0)=P(S(n)).
So P(x)=x, substituting confirms it works.
- If a1=0, then it is easy to see that a0∈{1,…,9} all satisfy the requirements of the problem.