# 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 – Dr. belisarius Nov 26 '15 at 20:00
• Try multiplying the list by the LCM of the denominators; that will give you the list of numerators. – Patrick Stevens Nov 26 '15 at 20:08
• LCM@@Denominator[list]] might be what you want. – Daniel Lichtblau Nov 26 '15 at 20:38
• – jkuczm Nov 26 '15 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. – J. M.'s technical difficulties Nov 26 '15 at 22:56
• @J.M. Why? Is it seriuos difference? I've just put it to avoid ToString solution. – garej Nov 27 '15 at 6:20