randRange(1, 10) randRange(1, 9) randRange(M_NUM + 1, 10) getGCD(M_NUM, M_DENOM) M_NUM / GCD M_DENOM / GCD WHOLE * M_REDUCED_DENOM + M_REDUCED_NUM M_REDUCED_DENOM "\\dfrac{1}{" + I_DENOM + "}" "\\dfrac{" + I_DENOM + "}{" + I_DENOM + "}" $._("whole")

Rewrite fraction(I_NUM, I_DENOM, false, true) as a mixed number.

I_NUM / I_DENOM

\blue{fraction(I_NUM, I_DENOM, false, true)} is the same as the fraction FRACTION added I_NUM times.

We can add I_DENOM of the FRACTION fractions together to get 1 whole.

\qquad_(I_DENOM).times(function() { return FRACTION; }).join("+") = \green{WHOLE_FRAC}

init({ range: [[-3, 8], [-2, 2]], scale: 25 }); piechart([I_DENOM], [GREEN], 1.5); label([2, 0], WHOLE_FRAC + " = 1 \\text{ " + WHOLE_TEXT + "}", "right", { color: GREEN });

So we can write \blue{fraction(I_NUM, I_DENOM, false, true)} like this:

\blue{fraction(I_NUM, I_DENOM, false, true)} = _(WHOLE).times(function() { return "\\green{" + WHOLE_FRAC + "}"; }).join("+") + \pink{\dfrac{M_REDUCED_NUM}{I_DENOM}}

init({ range: [[-0.5, 10.5], [-0.5, 0.5]], scale: 40 }); for (var i = 0; i < WHOLE; i++) { piechart([I_DENOM], [GREEN], 0.48, "#fff", i); } piechart([M_REDUCED_NUM, I_DENOM - M_REDUCED_NUM], [PINK, '#bbb'], 0.48, "#fff", WHOLE);

\green{WHOLE_FRAC} = \green{1\text{ WHOLE_TEXT}}, so we can rewrite our equation like this:

\blue{fraction(I_NUM, I_DENOM, false, true)} = _(WHOLE).times(function() { return "\\green{1}"; }).join("+") + \pink{\dfrac{M_REDUCED_NUM}{I_DENOM}}

\blue{fraction(I_NUM, I_DENOM, false, true)} = \green{WHOLE} + \pink{\dfrac{M_REDUCED_NUM}{I_DENOM}}

The mixed number is WHOLE\dfrac{M_REDUCED_NUM}{I_DENOM}

Rewrite WHOLEfraction(M_NUM, M_DENOM, false, true) as a fraction, \dfrac{a}{b}, where a > b.

I_NUM / I_DENOM

\blue{WHOLEfraction(M_NUM, M_DENOM, false, true)} = \green{WHOLE} + \pink{fraction(M_NUM, M_DENOM, false, true)}

\blue{WHOLEfraction(M_NUM, M_DENOM, false, true)} = _(WHOLE).times(function() { return "\\green{1}"; }).join("+") + \pink{fraction(M_NUM, M_DENOM, false, true)}

init({ range: [[-0.5, 10.5], [-0.5, 0.5]], scale: 40 }); for (var x = 0; x < WHOLE; x++) { circle([x, 0], 0.48, { fill: GREEN, stroke: null }); } piechart([M_REDUCED_NUM, I_DENOM - M_REDUCED_NUM], [PINK, '#bbb'], 0.48, "#fff", WHOLE);

\green{1\text{ WHOLE_TEXT}} = \green{WHOLE_FRAC}, so we can rewrite our equation like this:

\blue{WHOLEfraction(M_NUM, M_DENOM, false, true)} = _(WHOLE).times(function() { return "\\green{" + WHOLE_FRAC + "}"; }).join("+") + \pink{fraction(M_NUM, M_DENOM, false, true)}

init({ range: [[-0.5, 10.5], [-0.5, 0.5]], scale: 40 }); for (var i = 0; i < WHOLE; i++) { piechart([I_DENOM], [GREEN], 0.48, "#fff", i); } piechart([M_REDUCED_NUM, I_DENOM - M_REDUCED_NUM], [PINK, '#bbb'], 0.48, "#fff", WHOLE);

Now we can add the fractions:

\blue{WHOLEfraction(M_NUM, M_DENOM, false, true)} = \green{\dfrac{I_DENOM * WHOLE}{I_DENOM}} + \pink{\dfrac{M_REDUCED_NUM}{I_DENOM}}

\blue{WHOLEfraction(M_NUM, M_DENOM, false, true)} = fraction(I_NUM, I_DENOM, true, true)

The fraction is fraction(I_NUM, I_DENOM, true, true).