答案1
您可以尝试以下方法:
$$
\begin{array}{|l}
\llap{2~~~~} 12600 \\ \hline
\llap{2~~~~} 6300 \\ \hline
\llap{2~~~~} 3150 \\ \hline
\llap{5~~~~} 1575 \\ \hline
\llap{5~~~~} 315 \\ \hline
\llap{7~~~~} 63 \\ \hline
\llap{3~~~~} 9 \\ \hline
3
\end{array}
$$
以下是渲染的输出数学:
答案2
这里我创建了\mydiv
来实际进行计算,如果您提供连续的素因数。语法是\mydiv[<dividend>]{<divisor>}
。如果<dividend>
省略 ,则使用先前计算的被除数。
该宏会检测因式分解何时完成。
如果您实际输入了非因素,则会出现错误。
如果 Mathjax 不允许访问stackengine
,我已经提供了简化的代码来代替它......
\documentclass{article}
\def\rlwd{.5pt} \def\rlht{\dimexpr\dp\strutbox+\ht\strutbox} \def\rldp{.75ex}
\newcommand\mydiv[2][\relax]{\noindent%
\if\relax#1\relax%
\xdef\theremainder{\the\numexpr\dividend - %
\numexpr\numexpr\dividend/\divisor\relax*\divisor\relax\relax}%
\xdef\dividend{\the\numexpr\dividend/\divisor\relax}%
\else%
\xdef\dividend{#1}%
\xdef\theremainder{0}%
\fi%
\xdef\divisor{#2}%
\ifnum\dividend=\divisor\finishmydiv\checkfactor\else%
\makebox[3ex][r]{#2}~\setbox0=\hbox{~$\dividend$}%
\dumbstackengine{-\rlwd}{\rule[-\rldp]{\rlwd}{\rlht}~\dividend}{\rule{\dimexpr4pt+\wd0}{\rlwd}}%
\checkfactor%
\\%
\fi%
}
\def\finishmydiv{%
\makebox[3ex][r]{}\hspace{\dimexpr1ex%
}~\dividend\relax}
\def\checkfactor{\ifnum\theremainder=0\relax\else\ [Remainder${}=\theremainder$]\fi}
%%% \EITHER THIS (IF stackengine IS NOT AVAILABLE+)
%\makeatletter
%\global\newlength\@stackedboxwidth
%\newlength\@boxshift
%\newsavebox\@addedbox
%\newsavebox\@anchorbox
%\newcommand*\dumbstackengine[3]{%
% \sbox{\@anchorbox}{$#2$}%
% \sbox{\@addedbox}{$#3$}%
% \setlength{\@stackedboxwidth}{\wd\@anchorbox}%
% \ifdim\wd\@addedbox>\@stackedboxwidth%
% \setlength{\@stackedboxwidth}{\wd\@addedbox}%
% \fi%
% \setlength{\@boxshift}{\dimexpr-\dp\@anchorbox -\ht\@addedbox -#1}%
% \usebox{\@anchorbox}%
% \hspace{-\wd\@anchorbox}%
% \raisebox{\@boxshift}{\usebox{\@addedbox}}%
% \hspace{-\wd\@addedbox}%
% \hspace{\@stackedboxwidth}%
%}
%\makeatother
%%% OR
\usepackage{stackengine}
\newcommand*\dumbstackengine[3]{\stackengine{#1}{#2}{#3}{U}{l}{F}{F}{S}}
%%%
\begin{document}
\mydiv[12600]{2}
\mydiv{2}
\mydiv{2}
\mydiv{5}
\mydiv{5}
\mydiv{7}
\mydiv{3}
\mydiv{3}\medskip
\mydiv[60]{3}
\mydiv{3}
\mydiv{5}
\mydiv{2}
\end{document}
大致基于我的回答如何输入短除法?