# Thread: writing division with latex

1. ## writing division with latex

ı want to write a code with latex which can give me the solution of a division with a picture.
ı aimed to say as all you remembered from elementary school while we were trying to solve a problem like this 12/5;
12 |___5__
-__| 2
2
we draw this simple picture so can ı write this in latex?

2. I think that the way I lay out the diagram for long division is different from that. If it's any help, here is an example of the code that I used some years ago when teaching a class how to do long division of polynomials. The code is
Code:
\begin{array}{r@{}rrrrl}
&&x^2&+7x&+10\\
\cline{2-5}
x-3\;|&\;x^3 &+ 4x^2& - 11x& - 25 \\
&x^3&-3x^2 \\
\cline{2-3}
&&7x^2&-11x \\
&&7x^2&-21x \\
\cline{3-4}
&&&10x&-25 \\
\cline{4-5}
\end{array}
It produces this:

$\displaystyle \begin{array}{r@{}rrrrl} &&x^2&+7x&+10\\ \cline{2-5} x-3\;|&\;x^3 &+ 4x^2& - 11x& - 25 \\ &x^3&-3x^2 \\ \cline{2-3} &&7x^2&-11x \\ &&7x^2&-21x \\ \cline{3-4} &&&10x&-25 \\ &&&10x&-30&\quad\mbox{The quotient is }x^2+7x+10. \\ \cline{4-5} &&&&5&\quad\mbox{The remainder is }5. \end{array}$

A simpler version for dividing 12 by 5 would look like this:
Code:
\begin{array}{r@{}r@{}r@{}}
&&2\\
\cline{2-3}
5\;|&\;1&2 \\
&1&0 \\
\cline{2-3}
&&2 \\
\end{array}
It gives this: $\displaystyle \begin{array}{r@{}r@{}r@{}} &&2\\ \cline{2-3} 5\;|&\;1&2 \\ &1&0 \\ \cline{2-3} &&2 \\ \end{array}$