Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 10 down vote accepted

Here's a way that seems to work:

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

enter image description here

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

enter image description here

To get the number back, merely do

Times @@ expr

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.