Permalink
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (75 sloc) 3.49 KB
<!DOCTYPE html>
<html data-require="math math-format word-problems">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Integer sums</title>
<script data-main="../local-only/main.js" src="../local-only/require.js"></script>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="FIRST_NUM">randRange(1, 100)</var>
<var id="SEQ_LENGTH">randRange(2, 6)</var>
<var id="DIFFERENCE">randRange(1, 2)</var>
<var id="TARGET_NUMBER">randRange(1, SEQ_LENGTH)</var>
<var id="C">DIFFERENCE * SEQ_LENGTH * (SEQ_LENGTH - 1) / 2</var>
<var id="SUM">FIRST_NUM * SEQ_LENGTH + C</var>
<var id="SEQ_TYPE">
(function() {
if (DIFFERENCE === 1) {
return new Plural(function(num) {
return i18n.ngettext("integer", "integers", num);
});
} else if (isOdd(FIRST_NUM)) {
return new Plural(function(num) {
return i18n.ngettext("odd number", "odd numbers", num);
});
} else {
return new Plural(function(num) {
return i18n.ngettext("even number", "even numbers", num);
});
}
})()
</var>
<var id="SEQUENCE">
(function() {
var sequence = "x";
for (var i = 1; i &lt; SEQ_LENGTH; i++) {
sequence += "+ (x + " + (i * DIFFERENCE) + ")";
}
return sequence;
})()
</var>
<var id="ANSWER">FIRST_NUM + (TARGET_NUMBER - 1) * DIFFERENCE</var>
</div>
<div class="problems">
<div>
<p class="problem">The sum of <code><var>SEQ_LENGTH</var></code> consecutive <var>plural_form(SEQ_TYPE, SEQ_LENGTH)</var> is <code><var>SUM</var></code>.</p>
<p class="question">What is the <var>ordinalThrough20(TARGET_NUMBER)</var> number in this sequence?</p>
<p class="solution" data-forms="integer"><var>ANSWER</var></p>
</div>
</div>
<div class="hints">
<p>Call the first number in the sequence <code>x</code>.</p>
<p>The next <var>SEQ_TYPE</var> in the sequence is <code>x + <var>DIFFERENCE</var></code></p>
<div>
<p>The sum of the <code><var>SEQ_LENGTH</var></code> consecutive <var>plural_form(SEQ_TYPE, SEQ_LENGTH)</var> is:</p><p>
</p><p><code><var>SEQUENCE</var> = <var>SUM</var></code></p>
</div>
<p><code><var>SEQ_LENGTH</var>x + <var>C</var>= <var>SUM</var></code></p>
<p><code><var>SEQ_LENGTH</var>x = <var>SUM - C</var></code></p>
<p><code>x = <var>FIRST_NUM</var></code></p>
<div data-if="TARGET_NUMBER === 1">
<p>Thus, the first number is <code><var>ANSWER</var></code>.</p>
</div>
<div data-else data-unwrap>
<p>
Since <code>x</code> is the first number, <code>x + <var>(TARGET_NUMBER - 1) * DIFFERENCE</var></code>
is the <var>ordinalThrough20(TARGET_NUMBER)</var> <var>SEQ_TYPE</var>.
</p>
<div>Thus, the <var>ordinalThrough20(TARGET_NUMBER)</var> number in the sequence is <code><var>ANSWER</var></code>.</div>
</div>
</div>
</div>
</body>
</html>