Rewriting partitions using exponents
DisplayForm@RowBox@
Riffle[If[#2 == 1, #1, #1^#2] & @@@
Tally[HoldForm /@ {2, 2, 1, 50, 50, 50}],
"\[ThinSpace]"]
$2^2\, 1\, 50^3$
You can also apply TraditionalForm
and TeXForm
gracefully on this (but only after DisplayForm
.
Update
Fix issue pointed out by @ZeroTheHero
Tally[{2, 2, 1, 1}] /. {x_Integer, y_Integer} :> If[y == 1, y, Defer[x^y]]
(* {2^2, 1^2} *)
Tally[{2, 2, 1, 1}] /. {x_Integer, y_Integer} :> If[x == 1, x, Defer[x^y]]
(* {2^2, 1} *)
This may be useful:
Times @@ HoldForm /@ {2, 2, 1, 50, 50, 50}
1 22 503