Skip to content
This repository
Newer
Older
100644 71 lines (69 sloc) 3.084 kb
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
1 <!DOCTYPE html>
04c8cdcf » petercollingridge
2013-02-19 Use ordinal function
2 <html data-require="math math-format word-problems">
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
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>
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
12 <var id="SEQ_LENGTH">randRange(2, 6)</var>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
13 <var id="DIFFERENCE">randRange(1, 2)</var>
d430c30b » petercollingridge
2012-06-25 Implemented some suggestions
14 <var id="TARGET_NUMBER">randRange(1, SEQ_LENGTH)</var>
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
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>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
28 <var id="SEQUENCE">
29 (function() {
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
30 var sequence = "x";
344207c5 » petercollingridge
2013-02-20 Whitespacing
31 for (var i = 1; i &lt; SEQ_LENGTH; i++) {
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
32 sequence += "+ (x + " + (i * DIFFERENCE) + ")";
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
33 }
34 return sequence;
35 })()
36 </var>
d430c30b » petercollingridge
2012-06-25 Implemented some suggestions
37 <var id="ANSWER">FIRST_NUM + (TARGET_NUMBER - 1) * DIFFERENCE</var>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
38 </div>
39
40 <div class="problems">
41 <div>
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
42 <p class="problem">The sum of <var>SEQ_LENGTH</var> consecutive <var>SEQ_TYPE</var>s is <var>SUM</var>.</p>
04c8cdcf » petercollingridge
2013-02-19 Use ordinal function
43 <p class="question">What is the <var>ordinal(TARGET_NUMBER)</var> number in this sequence?</p>
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
44 <p class="solution" data-forms="integer"><var>ANSWER</var></p>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
45 </div>
46 </div>
47
48 <div class="hints">
e85f8b90 » petercollingridge
2013-02-20 Tweak hints
49 <p>Call the first number in the sequence <code>x</code>.</p>
d430c30b » petercollingridge
2012-06-25 Implemented some suggestions
50 <p>The next <var>SEQ_TYPE</var> in the sequence is <code>x + <var>DIFFERENCE</var></code></p>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
51 <div>
e85f8b90 » petercollingridge
2013-02-20 Tweak hints
52 <p>The sum of the <var>SEQ_LENGTH</var> consecutive <var>SEQ_TYPE</var>s is:<p>
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
53 <p><code><var>SEQUENCE</var> = <var>SUM</var></code></p>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
54 </div>
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
55 <p><code><var>SEQ_LENGTH</var>x + <var>C</var>= <var>SUM</var></code></p>
344207c5 » petercollingridge
2013-02-20 Whitespacing
56 <p><code><var>SEQ_LENGTH</var>x = <var>SUM - C</var></code></p>
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
57 <p><code>x = <var>FIRST_NUM</var></code></p>
d430c30b » petercollingridge
2012-06-25 Implemented some suggestions
58 <div data-if="FIRST_NUM === ANSWER">
59 <p>Thus, the first number is <code><var>ANSWER</var></code>.</p>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
60 </div>
323cdd76 » petercollingridge
2012-06-24 Working integer sum exercise
61 <div data-else>
04c8cdcf » petercollingridge
2013-02-19 Use ordinal function
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>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
66 </div>
e85f8b90 » petercollingridge
2013-02-20 Tweak hints
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>
5055c92f » petercollingridge
2012-06-23 Start integer sum exercise
68 </div>
69 </div>
70 </body>
71 </html>
Something went wrong with that request. Please try again.