Category Archives: Math & Programming Puzzles

Mentally Calculate Percentages of Large Numbers Quickly without using a calculator

The Infosplit Method

Lesson: Mentally Calculate Percentages of Large Numbers Quickly without using a calculator

Take the following large number:

$145,000

First chop it down

Percentages that end in 0 are simple to calculate mentally:

10% of $145,000 = $14,500

To take 10% We simply dropped a zero.

20% of $145,000 = a bit more thinking. Large percentages are easy to understand as smaller numbers.

Check out this pattern

(it should take you two seconds to make these mental assumptions)
10% = 10 (remove a zero from the end of the number or simply divide by 10)
20% = 5 (100% broken up 5 times creates pieces of 20%)
25% = 4 (100% broken up 4 times creates four pieces of 25%)
30% = 3/10 (divide by 10 and multiply by 3)
40% = 4/10 (divide by 10 and multiply by 4)
50% = 2 (divide by 2 or divide by 10 and multiply by 5)

To understand the above patterns, simply draw some squares on a piece of paper and section them into smaller pieces. These should come to you intuitively if you can visualize the operation.

Lets return to 20% of $145,000.

First, using our understanding that 20% means we are taking one fifth, we note:

145/5 and add three zeros.

Now 145 itself is a bit big, so will chunk this down to third grade math.

145 = 100 + 45.
100/5 = 20. (if you cant do this mentally you might need some help..)
45/5 = 9. (you should have memorized this in grade school..)
20 + 9 = 29.. and VOILA!

20% of 145,000 = 145/5 = 100/5 + 45/5 = 29 and three zeros! $29,000.

Easy when you break it down eh?

Complex Percentages

Some percentages are a bit more complex. For example:

14% of $94,500.

At first this might seem intimidating. Lets break down the percentage first.

14% = 10% + 4%. 4% = 1% + 1% + 1% + 1%. (You’ll see why in a moment).

Now we easily know 10% of $94,500 is $9,450 (we simply removed a zero).

4% is harder to calculate mentally, but we know that 4% is also 1% four times..

In this case, 1% ten times = $9,450 so we know 1% is 945. To get 4%, we simply do 945*4.

(split it up) 945*4 = 900*4 + 45*4.
900*4 = 9*4 (plus two zeros) = 3600.
45*4 = 40*4 + 5*4.
40*4 = 160.
5*4 = 20.
3600 + 160 + 20 = 3780.

So we know 4% = 3780. 9450 + 3780 = 9000 + 3000 + 400 + 700 + 50 + 50 + 30 (split 80 into 50+30).
9 + 3 = 12 (three zeros)
4 + 7 = 11 (one place over)
50 + 50 + 30 = 130 (two places over)
So we have 12000 + 1100 + 100 + 30 = 13230.

So 14% of $94,500 = $13,230. Another one of simply looking at this is 945*10 + 945*4.

The above example was a bit verbose to explain the steps your thoughts should take.

Lets try another one to show the mental math at work.

Mental Magic

Read through this one, then try it in your head. You might be surprised how easy it is.

27% of $132,000

132*10 + 132*10 + 132*7.
1320 + 1320 = 2640. (this shouldnt be too bad to keep in your head while you do the next one)
132*7 = 100*7 + 30*7 + 2*7. 700 + 210 + 14. 910 + 14 = 924.
2640 + 400 + 500 + 24 = 3040 + 400 + 24 = 3540 + 24 = 3564.

Add one zero and.. VOILA! $34,640. So 27% of 132,000 = 35,640.

What if the last two digits don’t end in zero?

We make it end in zero. How? Very easily.

More Complex Numbers

Take this number for example (made this one a bit smaller in case you are not used to big numbers):

83% of $47,139

Ugly eh? This one is more of a toughy and will be split four times. However.. commit 139 to memory and now you have 47,000.

83% can be broken a few different ways. You will likely learn towards one way or another. The more you practice, the less you need to break it down.

50% + 20% + 10% + 3%.
50% of 47 = 23.5
20% of 47 = 47/5 = 45/5 + 2/5 = 9.4 (remainder 2 on division by 5 is always .4)
10% of 47 = 4.7
3% of 47 = .47*3 = .4*3 = 1.2 + .07 * 3 = 1.2 + .21 = 1.41

Add it all up. 23.5 + 9.4 + 4.7 + 1.41 = 39.01.

Now readd the three zeros. 39,010. WAIT! Not done yet.. Remember 139?

83% of 139. Split it through 50/20/10/3 again.
69.5+26.5 = 70.5 + 27.5 – 1 + .3 = 96 + 1.3 + 13.9 = 109.9 + 1.3 + 1.39*3 = 110 – 0.1 + 4.17 + 1.3 = 114.07 + 1.3 = 115.37

39,010 + 115.37 = 39,125.37. Whew. Your brain might hurt after doing that in your head! And that took much longer than it would have on calculator!

You might be saying at this point.. Why place upon yourself such brutal mental torture?

If you’re a gym and exercise type of person, you already know the answer.. if you’re not this type of person.. then you should be! Eating fast food everyday and letting your PC do all your work is holding back your potential as a human being!

Also remember, for many practical purposes, if you’re trying to get a general estimate on something, obtaining a rounded percentage of 47,000 is very quick and easy.

A trick you will learn as you practice is deciding the shortest route to get the numbers you need.

The get 39,010 took me 14 mental very quick steps as written out above. If I wanted I could also figure 1% of 47,000 is 4.7. 4.7*83 = 83*4 + 83*.7 = 332 + 58.1 = 390.1. This is only 7 mental steps compared to 14.

You will notice as you practice more that an operation like 83*4 and 83*.7 will become mentally instantaneous since you have essentially memorized it, reducing the number of steps to three and solving it in about 3 seconds.

Who’s faster?

You might be saying to yourself at this point that either way the calculator will always be faster.. Not true!

Society has taught us to be dependent on machines for many tasks.. this makes you lazy! With some practice, and 15 minutes a day for a few weeks, you can retrain your brain to compute these operations faster than any PC.

Think about how much time you would save every day multiplied across your life if you could manage your finances or purchases without a calculator?

How to computer faster than your PC:

- Write down 10 simple examples ending in zeros and try to do them in your head. Keep the number sizes within the same place size, one hundred thousands etc or start with thousands and move up from there.

- Complexity is not necessarily the size of the number, but how easy the number is to break down.

- Try closing your eyes when calculating. This will help eliminate visual distraction and your brain will focus better.

- Do 10 different examples every day in the evening and when you wake up in the morning.

- Increase the size range of the number over time, maintaining the same number of zeroes at the end and repeat this over the course of a few weeks.

- Challenge your friends or coworkers and they will behold in amazement as your outperform any computer on these operations!

A monkey wrench in all this is technically some numbers cannot be broken down, but after practicing you will be able to spot these quickly and these are highly improbable in your everyday life.

Food for thought

The key to this is memory. Your memory can be a very powerful tool, and like your body, the more you exercise it, the more you will realize learning everything else will become that much easier.

If you have the diligence to try this exercise for at least two months, a phenomenon will happen to you..

- Economics, Stocks and personal financials will begin to seem simpler.

- You won’t get mentally exhausted as easily; you will have more mental stamina.

- Certain trends may become more apparent to you since your mind will begin to add things subconsciously without you even noticing it. You may begin to notice traffic patterns at intersections while driving, cloud patterns on different days, and other interesting details in your everyday life which may change the way you see many things.

Enjoy.

References
Prime Numbers, http://en.wikipedia.org/wiki/Prime_number

The Gameshow

Congratulations! You three contestants have made it to the final round of…

    The Greatest Gameshow On Earth !

The crowd screams wild in anticipation and the world watches on simultaneous webcasts and TVs as we approach the conclusion of our show..

Across from you on the stage, on a large screen, you will notice a large timer marked “60″. When I give the call, this timer will count down and you will have 60 seconds to answer the question correctly..

In center stage, behold my lovely assistant.. former miss america, miss universe, swimsuit model and overnight superstar… She is the singing voice of the hit single – “Computers are Cool” and young CEO of the popular fashion magazine company known as “Fashion Two-Point-Oh”… the beautiful Vana Blue!

In Ms. Blue’s arms is a box containing four party hats.. Contestants, please step forward and prepare yourselves to press the large red button in the center of your podiums.. Ms. Blue will now make her way behind each of you, and out of sight, will remove the hats from the box and place them on your heads one by one, until only one hat rests in the box.

With the box still closed, she will now make her way behind the door to my left into a room with no other exits and place the last hat upon her own head while she is out of sight.

Each of you contestants may look to your left and right and notice the color of the hat worn by the other contestants, but you cannot look at your own.

And now, for the final challenge to see who will win the 1 billion dollar grand prize..

Out of all four hats, including the one worn by Ms. Blue in the closed off room – two of the hats are blue, the other two hats are red.

You cannot attempt to communicate with your other contestants verbally or with gestures, any cheating will result in instant disqualification and no consolation award either!

You may only push the red buzzer on your podium once – you only get one try! If the timer reaches 60 or if each of you fail to answer correctly, no one wins!

To succeed, you must guess: What color is the hat you are wearing on your head?

The timer begins… Now!

References:
Wikipedia, http://en.wikipedia.org/wiki/Hat_puzzle

Uniform distribution

Impossible?

Puzzle:

This one is (supposedly) from a job interview for Google:

You’re being streamed an array of numbers. Every second you receive the next cell in the array. The array is finite but you don’t know when it ends or what’s it total length. Your job is to randomly pick one of the numbers from the array so that every number has the same probability of being selected i.e. if the array happens to be 10 cells long, each cell will have a probability of exactly 1/10 of being selected.

The catch is that you cannot locally save the array since that might take too much space. How do you do it?

(Courtesy of NewOrder Computer Security and Network Portal)

Potential Solution:

In probability and statistics there are two types of Uniform distribution, discrete and continuous. The above problem is an example of discrete, defined when – in a sequence of variables, a random variable has any of n possible values that are equally probable.

A popular example of discrete uniform distribution is known as the German tank problem. During World War II Allied intelligence used statistical methods to accurately predict production of German tanks using samples of data (ranges of variables over time which formed discrete uniform distribution).

To solve the above problem, the following sample C# code implements a simple algorithm:

First, we create a fraction class. (This is not absolutely necessary but will come in useful later.)

C#:

public class Fraction
    {
        public int numerator;
        public int denominator;

        public Fraction(string F)
        {
            numerator = Convert.ToInt32(F.Split('/')[0]);
            denominator = Convert.ToInt32(F.Split('/')[1]);
        }

        public static Fraction operator +(Fraction F1, Fraction F2)
        {
            int CD = F1.denominator*F2.denominator; //To find common denominator.

            F1.numerator *= CD/F1.denominator;
            F2.numerator *= CD/F2.denominator;

            return new Fraction((F1.numerator + F2.numerator).ToString() + '/' + CD.ToString());
        }

        public static Fraction operator +(Fraction F1, int _F2)
        {
            Fraction F2 = new Fraction(_F2.ToString() + '/' + 1.ToString());
            return F1+F2;
        }

        public static Fraction operator +(int _F1, Fraction F2)
        {
            Fraction F1 = new Fraction(_F1.ToString() + '/' + 1.ToString());
            return F1 + F2;
        }

        public override string ToString()
        {
            return numerator.ToString() + '/' + denominator.ToString();
        }

    }

And now for the main static class:

C#:

static class Program
    {
        static void Main(string[] args)
        {

            int N = 1; //N=Number of values received/generated.
            int ReceivedValue = GetNextNumber();

            if (args.Length > 0) { N = Convert.ToInt32(args[0]); } 

            Console.WriteLine("");
            Console.WriteLine("N={0},Value={1}", N.ToString(), ReceivedValue.ToString());

            Console.WriteLine(SelectNumber(new Fraction(string.Format("1/{0}", N)), ReceivedValue).ToString());

            System.Threading.Thread.Sleep(3000); //Increased timer to make more human readable.

            Main(new string[] {(N + 1).ToString()});
        }

        static int GetNextNumber()
        {
            int ArbitraryValue = 100; //May be any value, dynamic or static.
            Random RGen = new Random();
            int RValue = RGen.Next(1, ArbitraryValue);
            RGen = null;
            return RValue;
        }

        static int SelectNumber(Fraction P, int LastReceivedValue) //P=Probability. 1/N
        {
            int N = P.denominator;

            Random RGen = new Random();
            if (N == 1) { return 1; }
            else
            {
                int RValue = RGen.Next(1, N);
                RGen = null;
                if (!(RValue <= LastReceivedValue)) { return SelectNumber(P, LastReceivedValue); } else { return RValue; };
            }            
        }
    }

To test our algorithm, we must apply the following induction (proof) to assure correctness:

If n = the quantity of numbers arrived so far, for n=1 (the first number arrived), we pick a number with a probability of 1. This is uniform across one number.

For k = n the algorithm uniformly selects a number with probability 1/n.

For k=n+1 if the numbers have a uniform probability of being selected with the algorithm, when a new number arrives we pick it with probability 1/(n+1).

Probability of choosing the number 1 through n: (1/n) * (1-1/n+1) = (1/n)*(n/n+1) = 1/n+1.

Therefore probability of choosing the new number = 1/n+1.

To see it in action, compile and run the above code. Even if an external or different random permutation is used in the “SelectNumber” function, the value must be equal to the previous value to satisfy the probability requirements. Theoretically, an algorithm may be created which, by passing the previous value and probability (1/n+1), with a calculable expected standard deviation, a series of numbers could be randomly generated which are uniformly selected from a series of unknown arbitrary values.

I’m unsure if the above code is actually a pure solution to the problem since logic is applied in “SelectNumber” which causes RGen.Next to loop until the uniform requirements are met. In a true solution, it would seem to me that the value generated from a random algorithm such as “RGen.Next” should immediately satisfy the requirements, or with very minimal repeated loops.

Even though my solution uses the same .NET random generation algorithm for the arbitrary stream “GetNextNumber” as it does for “SelectNumber” (keep in mind this is also strictly not advised by MS), this puzzle does not really state and seems to suggest that these two algorithms should differ.

Without the ability to store locally/cache any values from the arbitrary stream – a pattern, series or algorithm does not seem to be identifiable, and therefore I do not think a random number can be generated in a single selection which is uniform across the stream, although (barring buffer overflows) within X multiple selections (approaching infinity) it is definitely possible.

Additional Info:

In .NET, the Random class actually implements Donald E. Knuth’s subtractive random number generator algorithm. For more information, see D. E. Knuth. “The Art of Computer Programming, volume 2: Seminumerical Algorithms”. Addison-Wesley, Reading, MA, second edition, 1981.

Modern applications of uniform distribution might include integrity testing of random permutation methods, algorithms and streams, (generating sequences of random numbers) which could be useful in encryption/decryption and (probably more useful), stock and financial market prediction.

More on stock market prediction using technical analysis to come soon.

Follow

Get every new post delivered to your Inbox.