Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

72 lines (69 sloc) 3.084 kB
<!DOCTYPE html>
<html data-require="math math-format word-problems">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Integer sums</title>
<script src="../khan-exercise.js"></script>
<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 "integer";
} else if (isOdd(FIRST_NUM)) {
return "odd number";
} else {
return "even number";
<var id="SEQUENCE">
(function() {
var sequence = "x";
for (var i = 1; i &lt; SEQ_LENGTH; i++) {
sequence += "+ (x + " + (i * DIFFERENCE) + ")";
return sequence;
<div class="problems">
<p class="problem">The sum of <var>SEQ_LENGTH</var> consecutive <var>SEQ_TYPE</var>s is <var>SUM</var>.</p>
<p class="question">What is the <var>ordinal(TARGET_NUMBER)</var> number in this sequence?</p>
<p class="solution" data-forms="integer"><var>ANSWER</var></p>
<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>
<p>The sum of the <var>SEQ_LENGTH</var> consecutive <var>SEQ_TYPE</var>s is:<p>
<p><code><var>SEQUENCE</var> = <var>SUM</var></code></p>
<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="FIRST_NUM === ANSWER">
<p>Thus, the first number is <code><var>ANSWER</var></code>.</p>
<div data-else>
Since <code>x</code> is the first number, <code>x + <var>(TARGET_NUMBER - 1) * DIFFERENCE</var></code>
is the <var>ordinal(TARGET_NUMBER)</var> <var>SEQ_TYPE</var>.
<div data-if="FIRST_NUM !== ANSWER">Thus, the <var>ordinal(TARGET_NUMBER)</var> number in the sequence is <code><var>ANSWER</var></code>.</div>
Jump to Line
Something went wrong with that request. Please try again.