# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
114 lines (102 sloc) 4.49 KB
 Greatest common divisor
randRange( 1, 10 ) randRange( 1, 10 ) randRange( 1, 5 ) A_START * FACTOR B_START * FACTOR getGCD( A, B ) getFactors( A ) getFactors( B ) _.intersection( A_FACTORS, B_FACTORS )

What is the greatest common divisor of A and B?

Another way to say this is:

\gcd(A, B) = {?}

GCD

The greatest common divisor is the largest number that divides evenly into both A and B.

Start by thinking about all of the numbers that divide evenly into A. In other words, what are the divisors of A?

The only divisor of 1 is 1 since that's the only number that divides evenly into 1:

The divisors of A are toSentence( getFactors( A ) ) since those are all the numbers that divide evenly into A:

A \div \color{BLUE}{F} = A/F

Start by thinking about all of the numbers that divide evenly into B. In other words, what are the divisors of B?

The only divisor of 1 is 1 since that's the only number that divides evenly into 1:

The divisors of B are toSentence( getFactors( B ) ) since those are all the numbers that divide evenly into B:

B \div \color{GREEN}{F} = B/F

To find the common divisors, find the all the divisors of A and divisors of B that are the same.

The only common divisor of A and B is GCD since that's the only number that divides evenly into both A and B.

The common divisors of A and B are toSentence( COMMON_FACTORS ) since each of those numbers divides evenly into both A and B. We're interested in the greatest common divisor.

jQuery( "span.hint_pink" ).show();

The greatest common divisor of A and B is GCD. In other words, \gcd(A, B) = GCD.

Something went wrong with that request. Please try again.