# publicKhan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Older
100644 71 lines (69 sloc) 3.084 kb
 ``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 1 ``` 04c8cdcf » petercollingridge ``` 2013-02-19 Use ordinal function 2 ``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 3 4 5 Integer sums 6 7 8 9
10
11 randRange(1, 100) ``` 323cdd76 » petercollingridge ``` 2012-06-24 Working integer sum exercise 12 randRange(2, 6) ``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 13 randRange(1, 2) ``` d430c30b » petercollingridge ``` 2012-06-25 Implemented some suggestions 14 randRange(1, SEQ_LENGTH) ``` 323cdd76 » petercollingridge ``` 2012-06-24 Working integer sum exercise 15 DIFFERENCE * SEQ_LENGTH * (SEQ_LENGTH - 1) / 2 16 FIRST_NUM * SEQ_LENGTH + C 17 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 ``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 28 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 < 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 ``` d430c30b » petercollingridge ``` 2012-06-25 Implemented some suggestions 37 FIRST_NUM + (TARGET_NUMBER - 1) * DIFFERENCE ``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 38
39 40
41
``` 323cdd76 » petercollingridge ``` 2012-06-24 Working integer sum exercise 42

The sum of SEQ_LENGTH consecutive SEQ_TYPEs is SUM.

``` 04c8cdcf » petercollingridge ``` 2013-02-19 Use ordinal function 43

What is the ordinal(TARGET_NUMBER) number in this sequence?

``` 323cdd76 » petercollingridge ``` 2012-06-24 Working integer sum exercise 44

``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 45
46
47 48
``` e85f8b90 » petercollingridge ``` 2013-02-20 Tweak hints 49

Call the first number in the sequence x.

``` d430c30b » petercollingridge ``` 2012-06-25 Implemented some suggestions 50

The next SEQ_TYPE in the sequence is x + DIFFERENCE

``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 51
``` e85f8b90 » petercollingridge ``` 2013-02-20 Tweak hints 52

The sum of the SEQ_LENGTH consecutive SEQ_TYPEs is:

``` 323cdd76 » petercollingridge ``` 2012-06-24 Working integer sum exercise 53

SEQUENCE = SUM

``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 54
``` 323cdd76 » petercollingridge ``` 2012-06-24 Working integer sum exercise 55

SEQ_LENGTHx + C= SUM

``` 344207c5 » petercollingridge ``` 2013-02-20 Whitespacing 56

SEQ_LENGTHx = SUM - C

``` 323cdd76 » petercollingridge ``` 2012-06-24 Working integer sum exercise 57

x = FIRST_NUM

``` d430c30b » petercollingridge ``` 2012-06-25 Implemented some suggestions 58
59

Thus, the first number is ANSWER.

``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 60
``` 323cdd76 » petercollingridge ``` 2012-06-24 Working integer sum exercise 61
``` 04c8cdcf » petercollingridge ``` 2013-02-19 Use ordinal function 62

63 Since x is the first number, x + (TARGET_NUMBER - 1) * DIFFERENCE 64 is the ordinal(TARGET_NUMBER) SEQ_TYPE. 65

``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 66
``` e85f8b90 » petercollingridge ``` 2013-02-20 Tweak hints 67
Thus, the ordinal(TARGET_NUMBER) number in the sequence is ANSWER.
``` 5055c92f » petercollingridge ``` 2012-06-23 Start integer sum exercise 68
69
70 71
Something went wrong with that request. Please try again.