Question: Get a^ib^jc^k from expand (a+b+c)^n

I want to write a function func(n) get a^ib^jc^k from expand (a+b+c)^n

Example

When n = 1 then (a + b + c)^1 = a + b + c and func(n) return {a, b, c}.

When n = 2 then (a + b + c)^2 = a^2 + b^2 + c^2 + 2ab + 2bc + 2ca and func(n) return {a^2, b^2, c^2, ab, bc, ca}.

When n = 3 then func(n) return {a^3, b^3, c^3, a^2b, b^2c, c^2a, ab^2, bc^2, ca^2, abc}.

I have solution using 3 loops but in think it's not nice, someone can help me. Thanks you very much.

Please Wait...