Showing posts with label mathematics. Show all posts
Showing posts with label mathematics. Show all posts

Friday, February 03, 2012

Teaching the kid how to factorize

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.

Sunday, May 08, 2011

A lesson in mathematics for a rickshaw driver

I had earlier written about how to compute the regular fare for the Mumbai autorickshaws. At the end of a rickshaw trip, I try to pronounce the fare computed from the meter reading. This usually impresses the rickshaw drivers. On a couple of occasions, I even tried explaining the mathematics to some of them.

Very recently, I found a rickshaw driver who was keenly interested in knowing this computation. When I explained the simple mathematics behind it, he was quite amazed. In fact, he was so grateful that he waived off a couple of rupees of the fare. I did not accept the reduction in fare, however, and paid the fare in full to the exact rupee.

Unfortunately, unlike for the regular fare, I was unable to come up with a curve fitting simple equation for the late-night (post-midnight) fare. Maybe I should've tried using a more advanced software such as MATLAB or Scilab or some other curve fitting tools.