# public Khan /khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

file 73 lines (65 sloc) 3.375 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         Adding fractions

randRange( 1, 9 )        randRange( N1 + 1, 13 )        getGCD( N1, D1 )        N1 / GCD1        D1 / GCD1        randRange( 1, 9 )        randRange( N2 + 1, 13 )        getGCD( N2, D2 )        N2 / GCD2        D2 / GCD2        getLCM( SIMP_D1, SIMP_D2 )

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

N1 / D1 + N2 / D2

1                2                getGCD( N1, D1 )                N1 / GCD1                D1 / GCD1                1                4                getGCD( N2, D2 )                N2 / GCD2                D2 / GCD2                getLCM( SIMP_D1, SIMP_D2 )

Simplify each fraction.

fraction( SIMP_N1, SIMP_D1 ) + fraction( SIMP_N2, SIMP_D2 )

Find a common denominator by finding the least common multiple of SIMP_D1 and SIMP_D2.

\lcm(SIMP_D1, SIMP_D2) = LCM

Change each fraction to an equivalent fraction with a denominator of LCM.

fraction( SIMP_N1, SIMP_D1 ) + fraction( SIMP_N2, SIMP_D2 )

=fraction( SIMP_N1, SIMP_D1 ) \cdot fraction( LCM / SIMP_D1, LCM / SIMP_D1 ) + fraction( SIMP_N2, SIMP_D2 ) \cdot fraction( LCM / SIMP_D2, LCM / SIMP_D2 )

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

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

Simplify.

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

Something went wrong with that request. Please try again.