Assume f(x)'s coefficients are all real;
Otherwise there is no unique solution.
Let f(x) = a(x-2)(x-b), where a and b are real to be determined. f(f(x)) has only one real zero 5, then 5 must be a multi-root. Then either f(x) - 2 = a(x-5)(x-5) or f(x) - b = a(x-5)(x-5) ( b cannot be 2....) . Now we almost done.
Let f(x) = a(x-2)(x-b), where a and b are real to be determined. f(f(x)) has only one real zero 5, then 5 must be a multi-root. Then either f(x) - 2 = a(x-5)(x-5) or f(x) - b = a(x-5)(x-5) ( b cannot be 2....) . Now we almost done.