# 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[[1]] &, x[[2]]]
fac[n_] := Flatten[Map[f[#] &, FactorInteger[n]]]


Example:

fac[24] 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[[1]]^x[[2]]] 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[24] /. Inactive[Power][a_, 1] :> a


Your fac[24] could be written as

Flatten[ConstantArray @@@ FactorInteger[24]]


To not show the ^ symbol:

Superscript @@@ FactorInteger[24] /. 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 at 21:53
See update ------------------------------------- – eldo Jan 11 at 22:01

From the docs:

CenterDot @@ Superscript @@@ FactorInteger[7!]


Though CenterDot does not work well for prime powers:

CenterDot @@ Superscript @@@ FactorInteger[5]


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[5]


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

-