So, one day when I return home, I find my wife desperately trying to teach the kid how to find all factors of a number in vain. The kid was unable to comprehend how to do it. After watching for a while, I decided to step in.
With the background in programming coming handy, I first explain what are prime numbers. Then, using the divide-and-conquer method, I show how to factorize.
For example, if the number is 36, I first say that the number itself and 1 are two of the factors.
36 = 36 x 1
Then, we choose a single factor which will divide the given number. For example, 9.
36 = 9 x 4
Now, repeat the above method for each of the factors until you reach prime numbers - numbers that cannot be factorized any further.
9 = 3 x 3
4 = 2 x 2
Since 3 and 2 are prime numbers, we are now in a position to find ALL the factors.
36 = 3 x 3 x 2 x 2
Now, form all possible combinations to get all the factors.
36 = 3 x (3 x 2 x 2) = 3 x 12
= (3 x 3 x 2) x 2 = 18 x 2
= (3 x 2) x (3 x 2) = 6 x 6
Add the ones found earlier, and that would complete the list of all the factors.
36 = 36 x 1
= 9 x 4
= 3 x 12
= 2 x 18
= 6 x 6
So, the factors of 36 are:
1, 36, 9, 4, 3, 12, 2, 18, 6
The above method has the advantage of being very fast, but it has the disadvantage that it becomes difficult if it is not easy to find the first factor.
With the background in programming coming handy, I first explain what are prime numbers. Then, using the divide-and-conquer method, I show how to factorize.
For example, if the number is 36, I first say that the number itself and 1 are two of the factors.
36 = 36 x 1
Then, we choose a single factor which will divide the given number. For example, 9.
36 = 9 x 4
Now, repeat the above method for each of the factors until you reach prime numbers - numbers that cannot be factorized any further.
9 = 3 x 3
4 = 2 x 2
Since 3 and 2 are prime numbers, we are now in a position to find ALL the factors.
36 = 3 x 3 x 2 x 2
Now, form all possible combinations to get all the factors.
36 = 3 x (3 x 2 x 2) = 3 x 12
= (3 x 3 x 2) x 2 = 18 x 2
= (3 x 2) x (3 x 2) = 6 x 6
Add the ones found earlier, and that would complete the list of all the factors.
36 = 36 x 1
= 9 x 4
= 3 x 12
= 2 x 18
= 6 x 6
So, the factors of 36 are:
1, 36, 9, 4, 3, 12, 2, 18, 6
The above method has the advantage of being very fast, but it has the disadvantage that it becomes difficult if it is not easy to find the first factor.
No comments:
Post a Comment