Fetching contributors…
Cannot retrieve contributors at this time
65 lines (59 sloc) 2.62 KB
<!DOCTYPE html>
<html data-require="math math-format">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Adding and subtracting fractions</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars" data-ensure="D1 !== D2">
<var id="S1">randFromArray([-1, 1])</var>
<var id="S2">randFromArray([-1, 1])</var>
<var id="D1">randFromArray(smallDenominators)</var>
<var id="D2">randFromArray(smallDenominators)</var>
<var id="N1">randRangeExclude(1, 9, [D1])</var>
<var id="N2">randRangeExclude(1, 9, [D2])</var>
<var id="LCM">getLCM(D1, D2)</var>
<var id="F1">LCM / D1</var>
<var id="F2">LCM / D2</var>
<var id="GCD">getGCD(S1 * F1 * N1 + S2 * F2 * N2, LCM)</var>
</div>
<div class="problems">
<div>
<div class="question">
<p><code><var>fraction(S1 * N1, D1)</var> + <var>fraction(S2 * N2, D2)</var> = {?}</code></p>
</div>
<div class="solution" data-type="rational"><var>S1 * N1 / D1 + S2 * N2 / D2</var></div>
</div>
</div>
<div class="hints">
<p><code>
\qquad =
<span data-if="S1 === -1">-</span>
\blue{\dfrac{<var>N1</var> \times <var>F1</var>}{<var>D1</var> \times <var>F1</var>}}
<span data-if="S2 === -1">-</span><span data-else>+</span>
\green{\dfrac{<var>N2</var> \times <var>F2</var>}{<var>D2</var> \times <var>F2</var>}}
</code></p>
<p><code>
\qquad =
<span data-if="S1 === -1">-</span>
\blue{\dfrac{<var>N1 * F1</var>}{<var>LCM</var>}}
<span data-if="S2 === -1">-</span><span data-else>+</span>
\green{\dfrac{<var>N2 * F2</var>}{<var>LCM</var>}}
</code></p>
<p><code>
\qquad =
\dfrac{
<span data-if="S1 === -1">-</span>
\blue{<var>N1 * F1</var>}
<span data-if="S2 === -1">-</span><span data-else>+</span>
\green{<var>N2 * F2</var>}
}{<var>LCM</var>}
</code></p>
<p><code>\qquad = <var>fraction(S1 * F1 * N1 + S2 * F2 * N2, LCM)</var></code></p>
<p data-if="GCD !== 1"><code>\qquad = <var>fractionReduce(S1 * F1 * N1 + S2 * F2 * N2, LCM)</var></code></p>
</div>
</div>
</body>
</html>