2

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.

3
  • 1
    It is not very clear if your question is about typesetting or calculating. For the former, why not $\frac{43365000}{17}=2550882+\frac{6}{17}$ ?
    – user4686
    Commented Oct 21, 2015 at 17:06
  • Well, it's about typesetting, with the caveat that, as a beginner, I am open to the suggestion I can calculate in LaTeX, rather simply transferring calculations from a calculator and risking typing errors. In short it's this: "What is the standardised way, in LaTeX to write '18 / 16 = 1 remainder 2' assuming there is one which uses agreeable symbols for the modulus, rather than typing it out in full?" Commented Oct 21, 2015 at 19:14
  • as in my other comment, I can only lament I don't know of a standardised way myself ;-). The macro in my answer should probably be a bit modified to use the input also for the left hand side of the equality, because as it stands the user must copy the numerator and denominator which is error prone.
    – user4686
    Commented Oct 21, 2015 at 19:31

2 Answers 2

3

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.

4
  • Yeah.... this is, I'd say, a sufficient answer to the question on the paper, so thanks, that's an awesome response which I can use. However, if you don't mind, to divert more specifically to my frustration, the question boils down to this: "Is there a standardised way in latex to say '19 / 17 is 1 remainder 2'"? In C you have the modulo "%" to just get the remainder, and in school you write "19 / 17 = 1r2". Is there an official LaTeX way? With mathematically sound symbols, for example, for the quotient and the remainder? Commented Oct 21, 2015 at 18:18
  • to the best of my knowledge I know of no LaTeX way; amsmath provides various notations for the integer congruences \pmod, \mod, \pod. The notation in my answer appears to me like the standard mathematical one when the input is a fraction, the remainder having a numerator less than the denominator, this is a way to display the result of euclidean division A=QB+R, or A/B=Q+R/B (for positive things).
    – user4686
    Commented Oct 21, 2015 at 19:27
  • by the way the 19/17=1r2 notation was completely unknown to me, this is a cultural thing depending on one's own country's educational system.
    – user4686
    Commented Oct 21, 2015 at 19:35
  • It's primary ( age 4-8 ) maths in England, to help children do sums while avoiding long division. Modulus isn't primary school maths though, so it's a surprise to discover it seems LaTeX does not to have default support for it? Thanks for your help! Commented Oct 21, 2015 at 20:40
2

FWIW, you could make use of longdiv to get the actual calculation and results for a given division operation. The below excerpt will produce the following:

\documentclass{report}
\input{longdiv}

\begin{document}
    \longdiv{43365000}{17}
\end{document}

enter image description here

1
  • Forgot to mention that you need to use the \input instead of \usepackage.
    – Some guy
    Commented Oct 21, 2015 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .