# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (75 sloc) 3.74 KB
 Prime factorization
0 0
getPrime()

What is the prime factorization of NUMBER?

NUMBER

Let us draw a factor tree.

init({ range: [ [-1, 2], [-1, 1] ], scale: [30, 30] }); label( [cx, y], NUMBER );
circle( [cx, y], 0.5 );

Because NUMBER is prime, its prime factorization is simply NUMBER.

getComposite() getPrimeFactorization( NUMBER ) SOLUTION.slice( 0, SOLUTION.length - 1 ) NUMBER

What is the prime factorization of NUMBER?

SOLUTION.join("x")

Let us draw a factor tree.

init({ range: [ [-1, FACTORIZATION.length + 2], [ -2 * FACTORIZATION.length - 1, 1] ], scale: [30, 30] }); label( [cx + 1, y], curr );
path( [ [cx + 1, y - 0.5], [cx, y - 1.5] ] ); path( [ [cx + 1, y - 0.5], [cx + 2, y - 1.5] ] ); y -= 2; cx += 1; curr = curr / factor; label( [cx - 1, y], factor ); circle( [cx - 1, y], 0.5); label( [cx + 1, y], curr );
circle( [cx + 1, y], 0.5);

The prime factorization of NUMBER is SOLUTION.join(" \\times ").