# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
83 lines (79 sloc) 3.87 KB
 Estimation with decimals
\$.map( randRange( 1000, 16000, randRange( 3, 7 ) ), function( n ){ return ( n / 1000 ).toFixed( randRange( 1, 2 ) ); } ) sum( \$.map( VALUES, round ) ) randFromArray( [ [ "jogging", "ran", "mile" ], [ "riding a bicycle ", "traveled", "mile" ], [ "collecting mushrooms", "collected", "pound" ], [ "painting a roof", "painted", "square foot" ], [ "harvesting grain", "harvested", "tonne" ] ] ) 0 \$.map( VALUES, function( i ){ if ( round( i ) < i ) { return "smaller than"; } else{ return "bigger or equal to"; } } ) (function() { var sum = 0; \$.each( VALUES, function( i, val ) { sum += parseFloat( val ); }); return roundTo( 2, sum ); })()

person( 1 ) has been TYPES[ 0 ] every day for the last VALUES.length days.

Given that person( 1 ) TYPES[ 1 ] the following amounts (in plural( TYPES[ 2 ] )) each day, estimate how much he( 1 ) TYPES[ 1 ] in total by first rounding each amount to the nearest whole number and then summing all the rounded amounts.

Day
" "
Amount
(in plural( TYPES[ 2 ] ))
i+1 val

Note that if you first sum the exact amounts (SUM.toFixed( 2 )) and then round, you'll get round( SUM ). For fun, pay attention to how this number compares with your estimate.

ANSWER plural( TYPES[ 2 ] )

Round all the numbers to the nearest TYPES[ 2 ] and add them up.

Day Amount Rounded Running total
i+1 val round( val ) ACC += round( val )

Therefore the estimate is ANSWER plural( TYPES[ 2 ] ).

Something went wrong with that request. Please try again.