Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 78 lines (75 sloc) 3.569 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
<!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 $.ngettext("integer", "integers", num);
                    });
                } else if (isOdd(FIRST_NUM)) {
                    return new Plural(function(num) {
                        return $.ngettext("odd number", "odd numbers", num);
                    });
                } else {
                    return new Plural(function(num) {
                        return $.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>
Something went wrong with that request. Please try again.