# public Khan /khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

file 135 lines (118 sloc) 6.86 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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 `    Adding and subtracting mixed numbers with like denominators

randRangeNonZero( -1, 1 )                ( PM === 1 ? "+" : "-")                randRange( 2, 19 )                ( PM === 1 ? randRange( 1, 19 ) : randRange( -W1 + 1, -1 ))
randRange( 3, 20 )                    randRange( 3, 20 )

randRange( 1, D1 - 1 )                    randRange( 1, D2 - 1 )
getGCD( N1, D1 )                N1 / GCD1                D1 / GCD1                getGCD( N2, D2 )                N2 / GCD2                D2 / GCD2                getLCM( SIMP_D1, SIMP_D2 )                getGCD( SIMP_N1 * LCM / SIMP_D1 + PM * SIMP_N2 * LCM / SIMP_D2 , LCM )

expr(["+", W1 + fraction( N1, D1 ), W2 + fraction( N2, D2 )]) = {?}

W1 + W2 + N1 / D1 + PM * N2 / D2

Separate the whole numbers from the fractional parts:

= \blue{W1} + \blue{fraction( N1, D1 )} SIGN \pink{abs( W2 )} SIGN \pink{fraction( N2, D2 )}

Bring the whole numbers together and the fractions together:

= \blue{W1} SIGN \pink{abs( W2 )} + \blue{fraction( N1, D1 )} SIGN \pink{fraction( N2, D2 )}

=W1 + W2 + \blue{fraction( N1, D1 )} SIGN \pink{fraction( N2, D2 )}

= expr(["+", W1 + W2, fraction( N1 + PM * N2, D2 )])

Combine the whole and fractional parts into a mixed number:

= W1 + W2 + fraction( SIMP_N1 * LCM / SIMP_D1 + PM * SIMP_N2 * LCM / SIMP_D2, LCM )

Simplify to lowest terms:

= W1 + W2 + fractionReduce( SIMP_N1 * LCM / SIMP_D1 + PM * SIMP_N2 * LCM / SIMP_D2, LCM )

-1                "-"                randRange( 2, 19 )                randRange( -W1 + 1, -1 )
randRange( 3, 20 )                    D2

randRange( 1, D2 - 1 )                    D2
D2                getGCD( N1 - N2 , LCM )

expr(["+", W1 + 1, W2 + fraction( N2, D2 )]) = {?}

W1 + 1 + W2 + PM * N2 / D2

Convert W1+1 into=\blue{W1} + \blue{fraction( N1, D1)} before subtracting. So the problem becomes:

= \blue{W1}\blue{fraction( N1, D1 )} SIGN \pink{abs( W2 )}\pink{fraction( N2, D2 )}

Separate the whole numbers from the fractional parts:

= \blue{W1} + \blue{fraction( N1, D1 )} SIGN \pink{abs( W2 )} SIGN \pink{fraction( N2, D2 )}

Bring the whole numbers together and the fractions together:

= \blue{W1} SIGN \pink{abs( W2 )} + \blue{fraction( N1, D1 )} SIGN \pink{fraction( N2, D2 )}

=W1 + W2 + \blue{fraction( N1, D1 )} SIGN \pink{fraction( N2, D2 )}

= expr(["+", W1 + W2, fraction( N1 + PM * N2, D2 )])

Combine the whole and fractional parts into a mixed number:

= W1 + W2 + fraction( N1 - N2, D2)

Simplify to lowest terms:

= W1 + W2 + fractionReduce( N1 - N2 , LCM )

`
Something went wrong with that request. Please try again.