# Represent a positive integer as a product of its factors

I am trying to illustrate some simple ideas with exponents. I can manually express something like $5^4$ as $5 \cdot 5 \cdot 5 \cdot 5$, but wondered how to get Mathematica to do that for me.

I found the example below in the documentation, but can't figure out how to "massage" it to work with a number that only has one factor, for example I would like $625$ to be represented as $5 \cdot 5 \cdot 5 \cdot 5$:

CenterDot @@ (Superscript @@@ FactorInteger[20!])


Any ideas would be appreciated.

Here's a way that seems to work:

CenterDot @@ Flatten[ConstantArray @@@ FactorInteger[20!]]


CenterDot @@ Flatten[ConstantArray @@@ FactorInteger[625]]


To get the number back, merely do

Times @@ expr


where expr is the name for the expression that results from the code above.

You can also make use of Inactive to allow you to calculate the value later.

Starting with march's solution and altering the Apply.

n = 20!;
t = Inactive[Times] @@ Flatten[ConstantArray @@@ FactorInteger[n]]
(* 2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*3*3*3*3*3*3*3*3*5*5*5*5*7*7*11*13*17*19 *)


t can be Activated to calculate the value.

Activate@t == n
(* True *)


Hope this helps