# Counting Can Be Really Tough

 Factorial, Permutation, and Combination

### How do I count?

On most calculators, you can find a factorial button (displayed in the picture here as x!, however it may just be ! on other calculators), a permutation button (nPr), and a combination button (nCr).
I’m going to attempt at explaining why you would ever need such buttons.  If you don’t have a calculator handy with these buttons, open up the computational knowledge engine WolframAlpha and standby.

### Factorial First

Suppose you have 3 songs that you would like to listen to. Let’s call those songs A, B, and C, and let’s assume they are in a playlist on your smart device.  You push the random playback button.  How many ways can your smart device play back those songs for you?
This question can be answered using factorials. Before I show you how this works, let’s simply list all the possible ways and count them up:
{ABC, ACB, BAC, BCA, CAB, CBA}
There seem to be only six ways the smart device can play the songs back to me.  What if there were 20 songs?  Listing them out is not an option anymore, so we need a clever way of counting when we have more than 3 songs.
Here is how we could have obtained the 6 ways systematically.  Your smart device must choose from 3 songs randomly to play the first song.  Once that is chosen, the device must choose randomly from two remaining songs for the second choice.  There is only one song remaining to choose from for the final song.  Thus, the number of ways to play 3 songs randomly is 3*2*1 = 6.  To visualize why we multiply, here is a tree diagram.
Descending products like these are factorials. Try it now.  Plug in 3! into your calculator by pushing 3 first and then the factorial button.  Or, simply type in 3! into WolframAlpha.
Now, try 20! in WolframAlpha. You should get 2 quintillion, 432 quadrillion, 902 trillion, 8 billion, 176 million, 640 thousand.  Or 2,432,902,008,176,640,000.
That would have taken a while to list out.

### Permutations

Suppose your playlist has 5 songs instead of 3.  Let’s call the songs A, B, C, D, and E.  From the previous section, we learned that the number of ways our smart device can play them all back to us is 5! = 120.
However, we have time to listen to only two of them.  How many ways can our smart device do this? We will first count them up the old fashioned way, by listing all the possibilities.  Here goes.
{AB, AC, AD, AE, BA, BC, BD, BE, CA, CB, CD, CE, DA, DB, DC, DE, EA, EB, EC, ED}
It looks like there are 20.  What if the playlist has 20 songs and you have time to listen to 6?  Do you want to list them out? Nope. So, let’s find an easier way of getting that 20 and apply it to the more difficult problem.
The smart device had 5 choices of songs for the first song.  Once it chose that song, it had 4 choices for the second.  So, the final count is 5*4=20.  Unlike the factorial, this product does not descend all the way down to 1.  It only considers permuting 2 of 5 values.
On the calculator function, n=5 and r=2.  So, plug in 5 nPr 2 into WolframAlpha to see what you get.
Likewise, 20 nPr 6 can be obtained by plugging this in OR by plugging 20*19*18*17*16*15 into the calculator.  One method is a little more quick and efficient.  You should confirm that this value is 27,907,200.

### Combinations

Suppose someone displays in front of you five gifts. Let’s call them gift A, B, C, D, and E for simplicity.  You are given the opportunity to select two of these gifts for yourself.  How many ways can you do this?  How is this different from the previous problem with listening to 2 of 5 songs?
If we have gifts AB or BA we have the same two gifts, and we don’t really care about the order in which we select them.  We need a way of not counting BOTH of those.  So, refining the list above, we will get
{AB, AC, AD, AE, BC, BD, BE, CD, CE, DE}
This can be quickly obtained by using nCr.  Here again, n=5 and r=2 because you want to select 2 of 5 things.  Plug in 5 nCr 2 to confirm the value 10.
How many ways can you be dealt two hole cards in Texas Hold ‘Em?  How many ways can you be dealt five cards in Five Card Draw?  For these two examples, n=52.  For the first example r=2, and for the second, r=5.
Use WolframAlpha again to find 52 nCr 2 and 52 nCr 5.
These numbers are 1326 and 2,598,960, respectively.
Congratulations! You’ve learned a few basics in counting!
Want to have more fun with WolframAlpha? Plug in your birthday to find out how old you are in days.  Plug in the city you live in for your city’s demographics and income statistics among other things.  Type in “maximum value of y=x-x^2” to find out that the maximum value of y=1/4 is obtained when x=1/2. Cool, huh?

## 7 thoughts on “Counting Can Be Really Tough”

1. I enjoyed this! I'm trying to get my quantitative brain together right now, and these little exercises helped. And you explained them well. Thanks!

Like

2. Glad you liked it. I'm considering writing more like this rather than writing out solutions to highly technical problems.

Like