Number of ways of forming 4 letter words using the letters of the word RAMANA

Solution 1:

Suppose you have a $4$ letter string composed of, say, $1$ distinct and $3$ identical letters

There would be $\frac{4!}{1!3!}$ permutations, also expressible as a multinomial coefficient, $\binom{4}{1,3}$

Similarly, for $2$ distinct, $2$ identical, and $3$ distinct, $1$ identical,
it would be $\binom{4}{2,2}\;$ and $\binom{4}{3,1}$ respectively.

In the polynomial expression $4!(1+x/1!)^3(1+x+x^2/2!+x^3/3!)$,
the 4! corresponds to the numerator, whatever the combination; the first term in $( )$ corresponds to choosing one or more from $R,M,N$; and the other term corresponds to choosing $1,2,$ or $3 A's$

It will become evident why this approach works if we expand the first term in ( ), and compare serially with your case approach by just using the appropriate coefficients to get terms in $x^4$

$4!(1 + 3x + 3x^2 + x^3)(1 + x + x^2/2! + x^3/3!)$

To find the coefficient of $x^4$, consider the three cases that produce $x^4$

One from $R,M,N, 3A's : 4!\cdot3\cdot\frac{1}{3!} = 12$
Two from $R,M,N, 2A's : 4!\cdot3\cdot\frac1{2!} = 36$
Three from $R,M,N, 1A : 4!\cdot1\cdot 1 = 24$

Coefficient of $x^4 = 12+36+24 = 72$

We can now clearly see why the coefficient of $x^4$ in the expression automatically gives all possible permutations of $4$ letters