# How to transform the output of FactorInteger to a traditional format?

I changed the FactorInteger output to a format which is more suitable to my needs.

I used:

f[x_] := Array[x[] &, x[]]
fac[n_] := Flatten[Map[f[#] &, FactorInteger[n]]]


Example:

fac yields {2,2,2,3}


Now, for presentation purposes only, I would like

{2^3, 3}


as the result of the function fac.

I tried several things such as:

HoldForm[2^3], which yields 2^3 as I would like, but


using the function

g[x_] := HoldForm[x[]^x[]] in fac instead of f


gives unexpected results.

How can I present the results of FactorInteger n as

{p1^a1, p2^a2, ... ,pn^an} i.e. ( 2^2, 5^3, 7 } ?


Inactive[Power] @@@ FactorInteger /. Inactive[Power][a_, 1] :> a Your fac could be written as

Flatten[ConstantArray @@@ FactorInteger] To not show the ^ symbol:

Superscript @@@ FactorInteger /. Superscript[a_, 1] :> a • Much better already but I don't want the ^ symbol in 2^3, I want the 3 lifted to the exponent place $2^3$ ( should have used Latex in question I suppose ). I tried adding //TraditionalForm but that did not work. – nilo de roock Jan 11 '16 at 21:53
• See update ------------------------------------- – eldo Jan 11 '16 at 22:01

From the docs:

CenterDot @@ Superscript @@@ FactorInteger[7!] Though CenterDot does not work well for prime powers:

CenterDot @@ Superscript @@@ FactorInteger If this is a problem, you could just define your own:

myCenterDot[e_] := e
myCenterDot[args__] := CenterDot[args]


Now it works fine:

myCenterDot @@ Superscript @@@ FactorInteger You could do something similar for Superscript if you don't want to see 1 in the exponents.

• Or without the dot, and using Times only for formatting: Times @@ Map[Superscript[#[], #[]] &, FactorInteger] – Christopher Lamb May 26 '19 at 4:14