let $f, g$ be two polynomial such that : $f(0)=-24 \ \ , \ \ g(0)=30$ and $\forall x \in \mathbb{R} : \ \ f(g(x))=g(f(x))$ 
let $f, g$ be two polynomial such that : $f(0)=-24 \ \  , \ \  g(0)=30$
and $$\forall x \in \mathbb{R} : \ \ f(g(x))=g(f(x))$$
then fine  :
$$ (f(3),g(6))=?$$


since :
$$\forall x \in \mathbb{R} : \ \ f(g(x))=g(f(x))\\f(g(0))=g(f(0))=f(30)=g(-24)\\f(g(3))=g(f(3))\\f(g(6))=g(f(6))$$
now:
$$f(g(6))=g(f(6))\to f(g(2\cdot3))=g(f(2\cdot3))$$
now what ?
 A: I shall assume that we want $f,g\in \Bbb Z[X]$ (or else $\gcd(f(3),g(6))$ make little sense).
If $g$ is constant, we need $f(30)=30$, but then $f(30)-f(0)=54$ is not a multiple of $30$, contradiction.
Similarly, if $f$ is constant, we need $g(-24)=-24$, but then $g(-24)-g(0)=-54$ is not a multiple of $-24$, contradictiom.
We conclude that neither $f$nor $g$ is constant.
Write  $f(x)=a_nx^n+a_{n-1}x^{n-1}+\ldots$ and $g(x)=b_mx^m+b_{m-1}x^{m-1}+\ldots$ with $a_n, b_m$ non-zero and $n\ge 1$, $m\ge 1$.
Then 
$$f(g(x))=a_nb_m^nx^{nm}+\ldots \qquad g(f(x))=b_ma_n^mx^{nm}+\ldots. $$
Equality is possible only in the following cases:


*

*$n=m=1$, $a_n,b_m$ arbitrary

*$n=1$, $a_n=1$, $b_m,m$ arbitrary

*$m=1$, $b_n=1$, $a_n,n$ arbitrary

*$a_n=b_m=1$, $n,m$ arbitrary.



In the first case, $f(X)=aX+30$, $g(X)=bX-24$, $f(g(X))=abX-24a+30$, $g(f(X))=abX+30b-24$, so in this case a necessary and sufficient condition is that $5b+4a=9$. 
We can parametrize this as $a=5k+1$, $b=-4k+1$.
Then $f(3)=3a+30=15k+33$, $g(6)=6b-24=-24k-18$.
From $8f(3)+5g(6)=174$, we conclude $\gcd(f(3),g(6))\mid 174=2\cdot 3\cdot 29$.
On the other hand, clearly $3\mid \gcd(f(3),g(6))$.
We have $2\mid \gcd(f(3),g(6))$ iff $k$ is odd.
We have $29\mid f(3)\iff k\equiv 21\pmod {29}$ and also $29\mid g(6)\iff k\equiv 21\pmod{29}$. 
In summary, the case of linear $f,g$ allows the following values for $\gcd(f(3),g(6))$:


*

*$3$, for example with $f(X)=X+30$, $g(X)=X-24$

*$6$, for example with $f(X)=6X+30$, $g(X)=-3X-24$

*$87$, for example with $f(X)=251X+30$, $g(X)=-199X-24$

*$174$, for example with $f(X)=106X+30$, $g(X)=-83X-24$



In the second case, $f(X)=X+30$, so $g(X+30)=g(X)+30$; it follows that $g(X)-X$ has period $30$, hence must be constant. This takes us back to the first case.

In the third case, $g(X)=X-24$, so $f(X-24)=f(X)-24$, and again we end up in the first case.

In the fourth case, we may assume $n\ge 2$ and $m\ge 2$.
This might be treated by consideraing the intermediate coefficients of $f(g(X))=g(f(X))$. (But at least it is still clear that $3\mid f(3)-f(0)$ and $6\mid g(6)-g(0)$, so $3\mid\gcd(f(3),g(6))$).
A: $f(x) = x-24$ and $g(x) = x+30$ satisfy the conditions. These give $f(3) = -21$ and $g(6) = 36$.
