X^x-31x+108=0

Now, if you meant

x^2-31x+108 = 0
then
(x-4)(x-27) = 0

x^x is a bit nastier