1
$\begingroup$

How to force Mathematica to output an expression such as

Input {2,3,4}-> Output 2*3*4=24

as a Times like this one:

Input Times[2,3,4] -> Output 24

$\endgroup$
1
  • 2
    $\begingroup$ do you mean you want to show the intermediate steps? Otherwise, you can try Times @@ lst where lst={2,3,4} $\endgroup$
    – Nasser
    Commented Mar 18, 2020 at 7:11

1 Answer 1

4
$\begingroup$
lst = {2, 3, 4};

Apply[Inactive[Times]]@# == Times @@ # &@lst

2*3*4==24

Or, for purposes of display,

Inactive[Set][Apply[Inactive[Times]]@#, Times @@ #] & @ lst

2*3*4=24

and

Row[{Inactive[Times] @@ #, Times @@ #}, "="] & @ lst

2*3*4=24

$\endgroup$

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.