Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 72 lines (69 sloc) 3.084 kb
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
1 <!DOCTYPE html>
04c8cdc Peter Collingridge Use ordinal function
petercollingridge authored
2 <html data-require="math math-format word-problems">
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Integer sums</title>
6 <script src="../khan-exercise.js"></script>
7 </head>
8 <body>
9 <div class="exercise">
10 <div class="vars">
11 <var id="FIRST_NUM">randRange(1, 100)</var>
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
12 <var id="SEQ_LENGTH">randRange(2, 6)</var>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
13 <var id="DIFFERENCE">randRange(1, 2)</var>
d430c30 Peter Collingridge Implemented some suggestions
petercollingridge authored
14 <var id="TARGET_NUMBER">randRange(1, SEQ_LENGTH)</var>
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
15 <var id="C">DIFFERENCE * SEQ_LENGTH * (SEQ_LENGTH - 1) / 2</var>
16 <var id="SUM">FIRST_NUM * SEQ_LENGTH + C</var>
17 <var id="SEQ_TYPE">
18 (function() {
19 if (DIFFERENCE === 1) {
20 return "integer";
21 } else if (isOdd(FIRST_NUM)) {
22 return "odd number";
23 } else {
24 return "even number";
25 }
26 })()
27 </var>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
28 <var id="SEQUENCE">
29 (function() {
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
30 var sequence = "x";
344207c Peter Collingridge Whitespacing
petercollingridge authored
31 for (var i = 1; i &lt; SEQ_LENGTH; i++) {
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
32 sequence += "+ (x + " + (i * DIFFERENCE) + ")";
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
33 }
34 return sequence;
35 })()
36 </var>
d430c30 Peter Collingridge Implemented some suggestions
petercollingridge authored
37 <var id="ANSWER">FIRST_NUM + (TARGET_NUMBER - 1) * DIFFERENCE</var>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
38 </div>
39
40 <div class="problems">
41 <div>
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
42 <p class="problem">The sum of <var>SEQ_LENGTH</var> consecutive <var>SEQ_TYPE</var>s is <var>SUM</var>.</p>
04c8cdc Peter Collingridge Use ordinal function
petercollingridge authored
43 <p class="question">What is the <var>ordinal(TARGET_NUMBER)</var> number in this sequence?</p>
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
44 <p class="solution" data-forms="integer"><var>ANSWER</var></p>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
45 </div>
46 </div>
47
48 <div class="hints">
e85f8b9 Peter Collingridge Tweak hints
petercollingridge authored
49 <p>Call the first number in the sequence <code>x</code>.</p>
d430c30 Peter Collingridge Implemented some suggestions
petercollingridge authored
50 <p>The next <var>SEQ_TYPE</var> in the sequence is <code>x + <var>DIFFERENCE</var></code></p>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
51 <div>
e85f8b9 Peter Collingridge Tweak hints
petercollingridge authored
52 <p>The sum of the <var>SEQ_LENGTH</var> consecutive <var>SEQ_TYPE</var>s is:<p>
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
53 <p><code><var>SEQUENCE</var> = <var>SUM</var></code></p>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
54 </div>
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
55 <p><code><var>SEQ_LENGTH</var>x + <var>C</var>= <var>SUM</var></code></p>
344207c Peter Collingridge Whitespacing
petercollingridge authored
56 <p><code><var>SEQ_LENGTH</var>x = <var>SUM - C</var></code></p>
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
57 <p><code>x = <var>FIRST_NUM</var></code></p>
d430c30 Peter Collingridge Implemented some suggestions
petercollingridge authored
58 <div data-if="FIRST_NUM === ANSWER">
59 <p>Thus, the first number is <code><var>ANSWER</var></code>.</p>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
60 </div>
323cdd7 Peter Collingridge Working integer sum exercise
petercollingridge authored
61 <div data-else>
04c8cdc Peter Collingridge Use ordinal function
petercollingridge authored
62 <p>
63 Since <code>x</code> is the first number, <code>x + <var>(TARGET_NUMBER - 1) * DIFFERENCE</var></code>
64 is the <var>ordinal(TARGET_NUMBER)</var> <var>SEQ_TYPE</var>.
65 </p>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
66 </div>
e85f8b9 Peter Collingridge Tweak hints
petercollingridge authored
67 <div data-if="FIRST_NUM !== ANSWER">Thus, the <var>ordinal(TARGET_NUMBER)</var> number in the sequence is <code><var>ANSWER</var></code>.</div>
5055c92 Peter Collingridge Start integer sum exercise
petercollingridge authored
68 </div>
69 </div>
70 </body>
71 </html>
Something went wrong with that request. Please try again.