I am trying to obtain all possible combinations of elements in a (long) list
factors = {A, B, C}; getCombinations[factors,n] For n = 3 factors, it should give
getCombinations[factors,3] {{{A^3, A^2 B, A^2 C}, {A B^2, A B C}, {A C^2}}, {{B^3, B^2 C}, {B C^2}}, {{C^3}}} I'm stuck trying to extend it for "n" number of factors.
For n=3 I have
len = Length[fac]; Table[fac[[i]]* Table[fac[[j]]* Table[fac[[k]], {k, j, len}], {j, i, len}], {i, 1, len}] SOLUTION (EDIT)
Both users cvgmt and Syed posted working solutions. Thank you so much! Based on the solution of cvgmt:
getCombinations[factors_, m_Integer] := Module[{list, n = Length[factors]}, list = FrobeniusSolve[ConstantArray[1, n], m]; Inner[Power, factors, #, Times] & /@ list // Sort] 