[Tex/LaTex] How to display Quotient + Modulus in LaTex

math-mode

Forgive me, it feels lame to ask such easy questions, but plowing through Google pages which don't appear to answer the question is maddening.

It is, I hope, very simple:

I'm trying to show, for maths homework, a top-heavy vulgar fraction rewritten as a whole number and a fraction.

The actual fraction is:

\frac{43,365,000}{17}

If anything below is bad form, do say:

The division by calculator gives:

2550882.3529411764705882352941176

To find the remainder, multiply integer part by 17 and I get:

43364994

Subtract this result from the numerator and I get:

43,365,000 - 43,364,994 = 6.

So, it's remainder 6.

So then, how do I typeset:

43,365,000 / 17 = 2550882 remainder 6?

So that I can get to the final answer, 2550882 and 6/17?

Surely LaTeX has a method to handle this?

Thanks.

PS. It's interesting(?) I can't use a "modulo"/"modulus" tag below, because there isn't one and I can't create it.

Best Answer

I don't know if you only want to display, or also calculate. Here is a proposal:

\documentclass{article}

\usepackage{xintfrac}

\newcommand\typesetintpartplusfracpart[2]{%
    \xintNum {#1/#2}+\xintFrac{\xintTFrac {#1/#2}}}

\begin{document}\thispagestyle{empty}
\[\frac{43365000}{17}=\typesetintpartplusfracpart{43365000}{17}\]

\[\frac {123456789012345678901234567890}{9876543210}
=\typesetintpartplusfracpart {123456789012345678901234567890}{9876543210}\]
\end{document}

Blockquote

In the second case common trailing zeros in the initial fraction are discarded from output, but that's the only simplification made. The package xintfrac has a macro \xintIrr that you could use to reduce the input to smallest terms first.

Or the output, for example:

\documentclass{article}

\usepackage{xintfrac}

\newcommand\typesetintpartplusfracpart[2]{%
    \xintNum {#1/#2}+\xintFrac{\xintIrr{\xintTFrac {#1/#2}}}}

\begin{document}
\[\frac{43365000}{17}=\typesetintpartplusfracpart{43365000}{17}\]

\[\frac {123456789012345678901234567890}{9876543210}
=\typesetintpartplusfracpart {123456789012345678901234567890}{9876543210}\]

\end{document}

Blockquote

Notice how the "modulo" part is reduced to smallest terms.