I have an expression like this:

3*Subscript[v, 0]^3*Subscript[v, 1]^8*Subscript[v, 2]^7*Subscript[v, 3]^2

I would like to extract the exponents and put them into a list sorted by the subscript and separate the constant factor. So I would like to have an output like this:

{3, {3,8,7,2}}

And in case the constant is missing in the expression, it should be output as 1, naturally. How can I achieve this? I tried sequence patter matching, but I did not succeed.


2 Answers 2


you can use


and get

{{3, 8, 7, 2} -> 3}

If we call your expression a then this should do the work


{{3, 8, 7, 2}, 3}


Try this (expr is your expression):

expr /. Times -> List /. {a_Integer, b__} :> {a, {b}}
MapAt[Total@Outer[Exponent, #, Array[Subscript[v, #] &, 4, 0]] &, %, 2]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.