# Khan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

169 lines (155 sloc) 6.472 kb
 Ordering Mixed Numbers and Improper Fractions
KhanUtil.shuffle([ "blue", "green", "red", "purple", "orange", "brown" ]) (function() { var ARRAY_LENGTH = 5; // constants for displaying fractions and mixed numbers var REDUCE = true; var SMALL_TYPESET = true; var DEFRACT = true; // Create random mixture of mixed numbers and improper fractions var MIXED_NUMBER = 1; var IMPROPER_FRACTION = 2; var TYPES = shuffle( [ MIXED_NUMBER, MIXED_NUMBER, MIXED_NUMBER, IMPROPER_FRACTION, IMPROPER_FRACTION, IMPROPER_FRACTION], ARRAY_LENGTH ); // calculate values so that they be accessed later in hints and solution var array = []; var used = {}; while ( array.length < ARRAY_LENGTH ) { var denominator = randRange( 2, 3 ) * randRange( 2, 5 ); // Since all are improper fractions, numerator is greater than denominator var numerator = randRange( denominator + 1, denominator + 15 ); var number = ( numerator / denominator ).toFixed( 3 ); var gcd = getGCD( numerator, denominator ); switch ( TYPES[ array.length ] ) { case MIXED_NUMBER: // If number is a whole number, try again if ( numerator % denominator !== 0 ) { if ( !used[ number ] ) { array.push( [ numerator / denominator, ( numerator / gcd ), ( denominator / gcd ), fraction( numerator, denominator, !DEFRACT, REDUCE ), COLORS[ array.length ], mixedFractionFromImproper( numerator, denominator, DEFRACT, REDUCE, SMALL_TYPESET ) ]); used[ number ] = true; } } break; case IMPROPER_FRACTION: if ( !used[ number ] ) { array.push([ numerator / denominator, ( numerator / gcd ), ( denominator / gcd ), fraction( numerator, denominator, !DEFRACT, REDUCE ), COLORS[ array.length ], fractionReduce( numerator, denominator, SMALL_TYPESET ) ]); used[ number ] = true; } break; } } return array; })() jQuery.map( NUMS, function( el ) { return el[ 2 ]; }) jQuery.map( NUMS, function( el ) { return "\\color{" + el[4] + "}{" + el[2] + "}"; }).join( "," ) getLCM.apply( KhanUtil, DENOMS ) jQuery.map( NUMS, function( el, idx ) { var n = el[ 1 ], d = el[ 2 ], scalar = (LCD/d); return "\\color{" + el[ 4 ] + "}{" + fraction( n * scalar, LCD ) + "}"; }) NUMS_LCD_COLOR.join( "," ) jQuery.map( NUMS, function( el ) { return "\\color{" + el[ 4 ] + "}{" + el[ 3 ] + "}"; } ).join( "," ) jQuery.extend( true, [], NUMS ).sort( function( a, b) { return a[0] - b[0]; }) jQuery.map( NUMS_SORT, function( el ) { return el[ 5 ]; }).join( "," ) jQuery.map( NUMS_SORT, function( el ) { return "\\color{" + el[ 4 ] + "}{" + el[ 5 ] + "}"; }).join( "," ) jQuery.map( NUMS_SORT, function( el, idx ) { var n = el[ 1 ], d = el[ 2 ], scalar = ( LCD / d ); return "\\color{" + el[ 4 ] + "}{" + fraction( n * scalar, LCD ) + "}"; }) NUMS_LCD_SORT_COLOR.join( "," ) createSorter()

Order the following fractions from least to greatest.

• NUM[ 5 ]

SORTER.init( "sortable" )

Drag the fractions or mixed numbers to the left or the right so they are in order from least to greatest
SORTER.getContent()
return guess.join( "," ) === NUMS_SORT_TEX;
SORTER.setContent( guess );

It's easier to compare fractions if they are all in the same form, so convert mixed numbers and whole numbers into improper fractions.

NUMS_TEX_COLOR

We can compare fractions when they have the same denominator. To make these fractions have the same denominator, we have to find the least common denominator. The least common denominator is the least common multiple of all the denominators. The least common multiple of DENOMS_TEX_COLOR is LCD.

We can change the denominator of fractions by multiplying by a form of 1, such as \dfrac{2}{2} or \dfrac{10}{10}. Multiply the improper fractions above by forms of 1 so that their denominators are all equal to LCD.

\color{NUM[4]}{NUM[3]}\times \dfrac {LCD / NUM[2] }{LCD / NUM[2]} = NUMS_LCD_COLOR[I]

Now all the fractions are in a form where we can compare them by numerator.

NUMS_LCD_TEX_COLOR

Sort the fractions from least to greatest by their numerators.

NUMS_LCD_SORT_COLOR_TEX

Finally, convert the numbers back to their original form.

MIXED_NUMS_SORT_TEX_COLOR

Something went wrong with that request. Please try again.