KhanUtil.shuffle([ "blue", "green", "red", "purple", "orange", "brown" ])
(function() {
var array = [];
var ds = [];
var used = {};
var arrLength = randRange( 4, 6 );
while ( array.length < arrLength ) {
var d = randRange( 1, 3 ) * randRange( 2, 9 );
var n = randRange( 1, d - 1 );
var ns = ( n / d ).toFixed( 3 );
if ( !used[ ns ] ) {
var gcd = getGCD( n, d );
array.push([ n/d,
(n/gcd),
(d/gcd),
fractionReduce( n, d, true ),
(n/gcd) + "/" + (d/gcd),
COLORS[array.length]
]);
ds.push( d/gcd );
used[ ns ] = true;
}
}
return array;
})()
jQuery.map( NUMS, function( el ) {
return el[2];
})
jQuery.map( NUMS, function( el ) {
return "\\color{" + el[5] + "}{" + 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[5] + "}{" + fractionSmall( n * scalar, LCD ) + "}";
})
NUMS_LCD_COLOR.join( "," )
jQuery.map( NUMS, function( el ) {
return el[3];
} ).join( "," )
jQuery.map( NUMS, function( el ) {
return "\\color{" + el[5] + "}{" + el[3] + "}";
} ).join( "," )
jQuery.extend( true, [], NUMS ).sort( function(a, b) {
return a[0] - b[0];
} )
jQuery.map( NUMS_SORT, function( el ) {
return el[3];
} ).join( "," )
jQuery.map( NUMS_SORT, function( el ) {
return "\\color{" + el[5] + "}{" + el[3] + "}";
} ).join( "," )
jQuery.map( NUMS_SORT, function( el, idx ) {
var n = el[1], d = el[2],
scalar = (LCD/d);
return "\\color{" + el[5] + "}{" + fractionSmall( n * scalar, LCD ) + "}";
})
NUMS_LCD_SORT_COLOR.join( "," )
createSorter()
Order the following fractions from least to greatest:
SORTER.init( "sortable" )
Drag the fractions left and right so they are in order from least to greatest
SORTER.getContent()
return guess.join( "," ) === NUMS_SORT_TEX;
SORTER.setContent( guess );
Let's use different colors for each fraction.
NUMS_TEX_COLOR
Find the least common denominator of all the fractions, so that we can compare them more easily.
The least common denominator is the least common multiple of all the denominators.
The least common multiple of DENOMS_TEX_COLOR
is LCD
.
Multiply all the fractions \dfrac{a}{b}
by \dfrac{\frac{LCD}{b}}{\frac{LCD}{b}}
. Then each fraction will have LCD
as its denominator:
\color{NUM[5]}{NUM[3]} \times \dfrac{\frac{LCD}{NUM[2]}}{\frac{LCD}{NUM[2]}}
= \color{NUM[5]}{NUM[3]} \times \frac{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, reduce each fraction again.
NUMS_SORT_TEX_COLOR