Let $R$ be any unital ring. What are the integers $n>1$ such that there is a polynomial $P(X) \in R[X]$ such that $P(P(X)) = X^n+1$ ?
If this is too general (I didn't even assume my ring to be commutative...), we can focus on the cases $R=\Bbb Z, \Bbb Q, \Bbb R, \Bbb C, \Bbb F_q$.
If we assume that $R$ is an integral domain, then $n = \text{deg}(P)^2$, I think, so we get a nice condition on $n$. Can we tell anything else?
When $R=\Bbb R$, I don't know if we could even find a continuous function $f : \Bbb R \to \Bbb R$ such that $f(f(x)) = x^n+1$ for every $n>1$...
Thank you for your help.