1. **Case 1: P(0)=0**
- If P(0)=0, then P(x)=xQ(x) for some polynomial Q(x) with integer coefficients.
- The sequence 0,P(0),P(P(0)),… is 0,0,0,…, which is trivially constant modulo any n.
- Therefore, any polynomial of the form P(x)=xQ(x) satisfies the condition.
2. **Case 2: P(x) is a constant polynomial**
- If P(x)=c for some integer c, then the sequence 0,P(0),P(P(0)),… is 0,c,c,…, which is eventually constant modulo any n.
- Therefore, any constant polynomial satisfies the condition.
3. **Case 3: P(x) is not constant and P(0)=0**
- Let P(x)=∑i=0daixi where d=deg(P)>0 and a0=P(0)=0.
- Define the sequence xn such that x0=0 and xn+1=P(xn). Then xn=Pn(0) for all n.
- Suppose p is a positive integer such that p∣Pi(0) for some i>1. Then for all positive integers k, we have:
Pki(0)≡P(k−1)i(0)≡⋯≡Pi(0)≡0(modp)
- Taking n=p in the condition, we get that xi is eventually constant modulo p, hence it must be eventually zero modulo p.
- Therefore, there exists N such that p∣xi for all i>N. Hence p∣xi and xi+1=P(xi)=∑j=0dajxij for large i.
- Since p∣ajxij for all j>0, p must divide a0=P(0).
- Thus, if a number divides Pi(0) for some i, then p must also divide P(0). So, Pi(0)∣P(0)⟹∣Pi(0)∣=∣P(0)∣ for all i.
4. **Subcase: P(P(0))=P(0)**
- If P(P(0))=P(0), then P(x)=(x−P(0))Q(x)+P(0) for some Q(x)∈Z[x].
- For x=0, we get Q(0)=0⟹Q(x)=xR(x) for some R(x)∈Z[x].
- Therefore, P(x)=x(x−P(0))R(x)+P(0).
- Then P(P(0))=P(0) and hence inductively Pi(0)=Pi+1(0) for all i>0, satisfying the condition.
5. **Subcase: P(P(0))=−P(0)**
- If P(P(0))=−P(0), we consider two subcases:
- **1st Subcase: P(P(P(0)))=P(0)=−P(P(0))**
- By induction, P2i+1(0)=P2i−1(0)=⋯=P(0) and P2i(0)=P2i−2(0)=⋯=P(P(0))=−P(0).
- However, taking n large enough, we have x2i+1−x2i=2P(0) divisible by n, which is a contradiction.
- **2nd Subcase: P(P(P(0)))=P(P(0))=−P(0)**
- Using P(P(0))=−P(0), there exists Q(x)∈Z[x] such that P(x)=(x−P(0))Q(x)−P(0).
- For x=P(P(0)), we get P(P(P(0)))=(P(P(0))−P(0))Q(P(P(0)))−P(0)=0⟹Q(P(P(0)))=0⟹Q(−P(0))=0.
- Therefore, Q(x)=(x+P(0))R(x) and P(x)=(x−P(0))(x+P(0))R(x)−P(0).
- For x=0, we get P(0)=−P(0)2R(0)−P(0)⟹P(0)R(0)=−2⟹R(0)=−2/P(0).
- Since P has integer coefficients, P(0) must be ±1 or ±2.
- Therefore, P(x)=(x−c)(x+c)(xS(x)−2/c)−c for c∈{1,−1,2,−2} and some S(x)∈Z[x].
In conclusion, the required polynomials are of the following forms:
- P(x)=c
- P(x)=xQ(x)
- P(x)=x(x−c)R(x)+c
- P(x)=(x−c)(x+c)(xS(x)−2/c)−c for c∈{1,−1,2,−2}, where Q(x),R(x),S(x) are polynomials with integer coefficients.
The final answer is P(x)=c, P(x)=xQ(x), P(x)=x(x−c)R(x)+c, and P(x)=(x−c)(x+c)(xS(x)−2/c)−c for c∈{1,−1,2,−2}, where Q(x),R(x),S(x) are polynomials with integer coefficients.