# Give a common denominator to a whole list

If I have a list, say $\{\frac{1}{36},\frac{1}{36},\frac{1}{18},\frac{1}{18},\frac{1}{12},\frac{1}{12},\frac{1}{12},\frac{1}{12},\frac{1}{12},\frac{1}{12},\frac{1}{12},\frac{1}{12},\frac{1}{18},\frac{1}{18},\frac{1}{36},\frac{1}{36}\}$, how can I make it so that all the elements of the list have the same denominator (using the smallest one possible) ?

• The real problem is how to get that numbers printed.Mathematica will simplify them on the fly. There are several related question to this on this site. Search for them Nov 26, 2015 at 20:00
• Try multiplying the list by the LCM of the denominators; that will give you the list of numerators. Nov 26, 2015 at 20:08
• LCM@@Denominator[list]] might be what you want. Nov 26, 2015 at 20:38
• Nov 26, 2015 at 22:59

l = {1/36, 1/36, 1/18, 1/12, 1/18};
lcm = LCM @@ (Denominator@l);
ToString[#]/lcm & /@ (l lcm);


If it is only for printing you could do something like this

list = {1/36, 1/36, 1/18, 1/12, 1/18};

max = Max@Denominator@list;
p1 = ToString /@ max/Denominator@list;
p2 = Array[ToString@max &, Length@list;

Column[#, Center, Spacings -> 1, Dividers -> Center] & /@ Transpose[{p1, p2}]


Not only for printing. One more option is to use HoldForm[] (or Defer[] suggested by J.M.):

Clear[list, den, print];
list = {1/36, 1/36, 1/18, 1/12, 1/18};


HoldForm:

den = Denominator@list;
print = HoldForm /@ (Max[den]/den)/Max[den]


To evaluate the expression:

ReleaseHold@print


PS. One may olso use Inactivate[]

• I would prefer Defer[] (or Inactivate[] in newer versions) myself. Nov 26, 2015 at 22:56
• @J.M. Why? Is it seriuos difference? I've just put it to avoid ToString solution. Nov 27, 2015 at 6:20

Using FractionBox:

For display only:

list = {1/36, 1/36, 1/18, 1/12, 1/18};

With [{z = LCM @@ Denominator@list},
FractionBox @@@
Transpose[{(list z), ConstantArray[z, Length@list]}] // DisplayForm
]


Inactive[Divide] @@@
Transpose[{(list z), ConstantArray[z, Length@list]}]


Activate[%]