How to solve linear Equation and factorial