# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
181 lines (160 sloc) 8.99 KB
 Adding and subtracting mixed numbers 1
randRangeNonZero(-1, 1) PM === 1 ? "+" : "-" randRange(2, 19) PM === 1 ? randRange(1, 19) : randRange(-W1 + 1, -1)
randRange(3, 20) randRangeExclude(3, 20, [D1])
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)

W1fraction(N1, D1) SIGN abs(W2)fraction(N2, D2) = {?}

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

\qquad = \blue{W1fraction(SIMP_N1, SIMP_D1)} SIGN \pink{abs(W2)fraction(SIMP_N2, SIMP_D2)}

\qquad = \blue{W1} + \blue{fraction(SIMP_N1, SIMP_D1)} SIGN \left(\pink{abs(W2)} + \pink{fraction(SIMP_N2, SIMP_D2)}\right)

\qquad = \blue{W1} + \blue{fraction(SIMP_N1, SIMP_D1)} SIGN \pink{abs(W2)} SIGN \pink{fraction(SIMP_N2, SIMP_D2)}

\qquad = \blue{W1} SIGN \pink{abs(W2)} + \blue{fraction(SIMP_N1, SIMP_D1)} SIGN \pink{fraction(SIMP_N2, SIMP_D2)}

\qquad = W1 + W2 + \blue{fraction(SIMP_N1, SIMP_D1)} SIGN \pink{fraction(SIMP_N2, SIMP_D2)}

\qquad = W1 + W2 + \blue{fraction(SIMP_N1 * LCM / SIMP_D1, LCM)} SIGN \pink{fraction(SIMP_N2 * LCM / SIMP_D2, LCM)}

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

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

\qquad = 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) randRangeExclude(3, 20, [D1])
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)

W1 + 1fraction(N1, D1) + W2fraction(N2, D2) = {?}

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

\qquad = \blue{W1 + 1fraction(SIMP_N1, SIMP_D1)} SIGN \pink{abs(W2)fraction(SIMP_N2, SIMP_D2)}

\qquad = \blue{W1 + 1fraction(SIMP_N1 * LCM / SIMP_D1, LCM)} SIGN \pink{abs(W2)fraction(SIMP_N2 * LCM / SIMP_D2, LCM)}

\qquad = \blue{W1 + fraction(LCM, LCM) + fraction(SIMP_N1 * LCM / SIMP_D1, LCM)} SIGN \pink{abs(W2)fraction(SIMP_N2 * LCM / SIMP_D2, LCM)}

\qquad = \blue{W1fraction(LCM + SIMP_N1 * LCM / SIMP_D1, LCM)} SIGN \pink{abs(W2)fraction(SIMP_N2 * LCM / SIMP_D2, LCM)}

\qquad = \blue{W1} + \blue{fraction(LCM + SIMP_N1 * LCM / SIMP_D1, LCM)} SIGN \left(\pink{abs(W2)} + \pink{fraction(SIMP_N2 * LCM / SIMP_D2, LCM)}\right)

\qquad = \blue{W1} + \blue{fraction(LCM + SIMP_N1 * LCM / SIMP_D1, LCM)} SIGN \pink{abs(W2)} SIGN \pink{fraction(SIMP_N2 * LCM / SIMP_D2, LCM)}

\qquad = \blue{W1} SIGN \pink{abs(W2)} + \blue{fraction(LCM + SIMP_N1 * LCM / SIMP_D1, LCM)}SIGN \pink{fraction(SIMP_N2 * LCM / SIMP_D2, LCM)}

\qquad = W1 + W2 + \blue{fraction(LCM + SIMP_N1 * LCM / SIMP_D1, LCM)} SIGN \pink{fraction(SIMP_N2 * LCM / SIMP_D2, LCM)}

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

\qquad = W1 + W2fraction((LCM + SIMP_N1 * LCM / SIMP_D1) + PM * SIMP_N2 * LCM / SIMP_D2, LCM)

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