Math & Sciencehow can it be written the least common denominator

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Krio
Posts: 2
Joined: Fri Feb 13, 2015 6:50 pm

how can it be written the least common denominator

Post by Krio »

I want to write something like
12|2 10|2
6|2 5|5
3|3 1|
1|

It can be one o more decompositions in prime numbers. I can't obtain and straight line. This example is the decomoposition of 12 (2x2x3) and 10 (2x5).

Thx

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

evaristegalois
Posts: 3
Joined: Sun Feb 15, 2015 6:11 pm

how can it be written the least common denominator

Post by evaristegalois »

How about

Code: Select all

\begin{equation}
  \label{eq:temp}
  \begin{array}{r|l}
    12 & 2 \\
    6 & 2 \\
    3 & 3 \\
    1 & 
  \end{array}\notag
\end{equation}
Krio
Posts: 2
Joined: Fri Feb 13, 2015 6:50 pm

how can it be written the least common denominator

Post by Krio »

Thx

The array approach is good to one lcd decomñposition but I see difficult to use in multiple lcd decompositions.

In a similar way, I used the tabular approach but it comes with some troubles. The next example show that the first decomposition has the line too large. I can order by size (first the 16 decomposition, in the middle the 12 decomposition and last the 10 decomposition) but I wonder that not exists a \decomposition command.

Code: Select all

\begin{tabular}{r|l r|l r|l}
12 & 2 &16 & 2 & 10 & 2\\
6 & 2 & 8 & 2 & 5 & 5\\
3 & 3 & 4 & 2 & 1\\ 
1 & &2 & 2\\
 &  & 1
\end{tabular}
\subsection{A subsection}
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

how can it be written the least common denominator

Post by rais »

Krio wrote: The array approach is good to one lcd decomñposition but I see difficult to use in multiple lcd decompositions.
I'm not sure what you're trying to achieve exactly---or should I say, what exactly your problem is?, but you can put more than one array environment into one math env.
If that's not enough, you can define your own environment, say

Code: Select all

\documentclass{article}
\newenvironment{denom}{%
  \setlength\arraycolsep{1.5pt}%
  \array[t]{@{}r|r@{}}}{\endarray}
\begin{document}
\[
\begin{denom}
12 & 2\\
6 & 2\\
3 & 3\\
1&
\end{denom}\quad
\begin{denom}
26 & 2\\
13 & 13\\
1&
\end{denom}\quad
\begin{denom}
256 & 2\\
128 & 2\\
64 & 2\\
32 & 2\\
16 & 2\\
8 & 2\\
4 & 2\\
2 & 2\\
1 &
\end{denom}
\]
\end{document}
Theoretically, you could take it even one step further to let (La)TeX do the calculations for you.
If I understand you right, that would mean something like parsing through prime numbers (starting at 2, but how far should they go?), check, if the number provided can be divided by the current prime number (and how often) ...

KR
Rainer
Post Reply