Hey everyone, this is Gary. This week I'm going on my first proper vacation in several years, and the first since I launched this podcast almost four years ago. As I'm going to be away from the microphone this week, I've lined up some shows from the archives that most of you haven't heard, and if you did, it'll be a good refresher. I'll be back again with new episodes on September 9th. Whenever there's a lottery, the odds of winning are given. If you go to a pizzeria, they may tell you the number of possible pizzas that can be made given their toppings.
If you have a combination lock, it's secured because of the number of different solutions that are possible. All of these things might seem different, but they're all part of the same branch of mathematics. Learn more about permutations and combinations, and how they work, on this episode of Everything Everywhere Daily. ♪
This episode is sponsored by NerdWallet. When it comes to general knowledge and history, you know I've got you covered. But who do you turn to when you need smart financial decisions? If your answer is NerdWallet, then you're absolutely right. And if it's not, let me change your mind.
The nerds at NerdWallet have spent thousands of hours researching and reviewing over 1,300 financial products. And they have the tools you need to make smarter financial decisions. Looking for a credit card? Go beyond the basic comparisons, filter for features that matter to you, and read in-depth reviews. Ready to choose a high-yield savings account? Get access to exclusive deals and compare rates, bonuses, and more. House hunting? View today's top mortgage rates for your home sweet home.
Make the Nerds your go-to resource for smart financial decisions. Head to nerdwallet.com forward slash learn more. NerdWallet, finance smarter. Disclosure, NerdWallet Compare Incorporated NMLS 1617539. What do Mattel, Banana Republic, ButcherBox, and Glossier all have in common? They power their businesses with Shopify. Shopify is the most innovative and scaled commerce platform on the planet.
that also happens to have the best converting checkout on the planet. And that's no industry secret. That's Shopify. Learn more at shopify.com slash enterprise. If you're not familiar with permutations and combinations, do not fear. It's a subject that often isn't covered in basic mathematics courses, but it also isn't that complicated. It involves nothing more than basic multiplication and division.
It doesn't necessarily even involve fractions or decimals, just whole numbers, and they can usually be explained using everyday things that you are familiar with. So to start this discussion, let's take a very simple case. How many ways can you arrange the numbers 1, 2, and 3? This is a pretty small number of things, so we could just brute force this and write them all out. There are 1, 2, 3, 1, 3, 2, 2, 1, 3, 2, 3, 1, 3, 1, 2, and 3, 2, 1.
So, there are six ways you can arrange the numbers 1, 2, and 3. Now let's say we wanted to do the same thing with 1, 2, 3, and 4. Well, that suddenly becomes much harder. Not ridiculously hard, but hard enough that you don't want to listen to me read out strings of numbers for the better part of a minute. Is there a way we could make a simple formula for calculating this? Well, there is. Let's say I have balls numbered 1, 2, 3, and 4 in Hopper, and I pull them out to create an arrangement.
For the first ball, there are four possibilities because all four balls are still in the hopper. Once I pull that ball out, there are now three possible balls that I could select. Once I pull that ball out, there are now two possible balls left, and then finally, there is only one ball left. So the total number of arrangements of the numbers 1 through 4 can be calculated by multiplying 4 by 3 by 2 by 1, or there are 24 ways.
In my first example, there were six ways to arrange three numbers, which is equal to 3 x 2 x 1. If I wanted to calculate the number of ways of arranging five numbers, it would be 5 x 4 x 3 x 2 x 1, or 120. This calculation where you multiply all of the numbers less than or equal to a given number has a special name and symbol in mathematics. And it's one that you might have encountered if you've used a calculator.
It's called a factorial, and its symbol is an exclamation mark. If you've ever played with the factorial key on a calculator, you may have discovered that it's very easy to create numbers so large that the calculator can't handle it. Factorials are just a shorthand for "multiply together this number and everything below it." To give you an idea of how quickly factorial numbers increase, 5 factorial as I mentioned is 120.
10 factorial is 3,628,800. And 15 factorial is 1,307,674,368,000. In fact, the numbers get so large so fast you can arrive at some surprising results. Take, for example, a deck of ordinary playing cards. There are 52 cards in the deck. How many different ways can a deck of playing cards be arranged?
This is fundamentally the same problem I addressed above, just with a bigger number. There are 52 possibilities for the first card, 51 for the second card, 50 for the third card, and so on. So the answer is 52 factorial. 52 factorial is a ridiculously large number. It starts with an 8 and then has 67 digits after it. There are more ways to shuffle a deck of cards than there are atoms in our entire galaxy.
Assuming that you have truly shuffled a deck of cards randomly, that means it is highly probable that the ordering of the cards in your hand is an ordering that has never existed before and probably will never exist again in history. If you shuffled a deck of cards every second since the universe began and each shuffle was a different arrangement of cards, you wouldn't have even come within a trillionth of one percent of all the possible arrangements.
The mathematical term for putting things in a particular order is known as a permutation. Now let's go back to my original example of arranging the numbers 1, 2, and 3. This time, let's assume that the numbers can repeat. 1, 2, 3 would be an arrangement, but 1, 1, 3 could be a possibility as well. This is actually really easy to figure out using the same method we did before. There are three possibilities for the first number, three for the second number, and three for the third number.
The answer is just 3 times 3 times 3, or 27. Or to write it more succinctly, 3 raised to the power of 3. For 4 numbers, it would be 4 to the power of 4, and 5 numbers would be 5 to the power of 5. These numbers grow even faster than factorials do. But now let's consider a different problem, where the order of things doesn't matter. Let's say you go to a pizza place, and they have 5 different toppings.
How many different ways can you make a three-topping pizza, assuming that you don't use any topping more than once? What makes this problem different from the earlier ones is that the order of the toppings doesn't matter. A pizza with olives, onions, and pepperoni is the same thing as one with pepperoni, olives, and onions. When the order doesn't matter, this is known as a combination. In mathematical parlance, you would say five pick three. To solve this problem, you first look at the number of ways you can pick three things out of five.
There are five possibilities for the first topping, four possibilities for the second topping, and three possibilities for the third topping. However, as I mentioned, order doesn't matter, so I've actually selected several redundant arrangements by doing this. We can correct for this by dividing that number by the total number of ways you can arrange three things, which is three factorial.
So the number of three topping pizza combinations out of five where there are no repeated toppings is 5 x 4 x 3 all divided by 3 x 2 x 1 or 10. Interesting side note, if you have a combination lock where you have a wheel and need to put numbers in a certain order to open it, it's actually a permutation, not a combination, because the order matters. So technically, combination locks should be called permutation locks.
Let's take this idea of combinations a bit further by looking at something with more numbers that you're still probably familiar with. The lottery. A typical lottery will involve taking several numbered balls out of a hopper containing many more balls. As with pizza toppings, the order of the balls doesn't matter. Just to use an example that many people listening to this will be familiar with, I'm going to use the Powerball lottery as an example.
This is a large lottery which is played in 45 U.S. states, as well as Washington, D.C., Puerto Rico, and the U.S. Virgin Islands. The game is played by selecting five numbers from a hopper containing 69 numbers, and then a power ball is selected from a different hopper containing 26 balls. First, let's look at the number of ways five balls can be selected from 69 balls. Again, the order doesn't matter, so in mathematical parlance, we would say 69 pick 5.
The number of permutations of 5 balls would be 69 times 68 times 67 times 66 times 65. We can actually make this a much simpler formula by just saying 69 factorial divided by 64 factorial. We get the 64 because it's 69 minus 5, the number of balls being selected. Again, that number contains many redundant combinations, so we have to divide that number by 5 factorial, the number of balls being selected.
The result is 11,238,513 possible five-number combinations out of 69 numbers. Those are pretty long odds, but they're actually much better odds than what you get in the actual game. And that's because there is a sixth number that comes from a separate hopper. As there are 26 balls in that hopper, and the Powerball number can match one of the other five numbers, we treat it separately and just multiply the previous result by 26.
So, 11,238,513 times 26 equals 292,201,338. So the odds of winning a single ticket is 1 in 292,201,338, which is exactly what you will find on the Powerball website and on a Powerball ticket.
Here is an interesting question. Why do they bother with the special Powerball? Why not just select 6 numbers from the main hopper instead of 5 and get rid of the Powerball? Well, take 69 factorial, divide by 63 factorial. And again, we get that number because we're selecting 6 numbers out of 69. We then take that result and divide it by 6 factorial, and the number we get is 119,877,472.
If they did it that way, the odds would be more than twice as good for players. Still astronomical, but much better. For most people, six numbers are six numbers. The fact that one of those numbers comes out of a separate hopper doesn't really seem relevant. However, the designers of Powerball weren't stupid, and they obviously did the math before they launched the game. They wanted odds that were long, but not too long. There are 330 million people in the United States. Most of them don't play the lottery every week.
That means for any given drawing, and there are two per week, no one will win the jackpot, and the prize will get rolled over to the next drawing. However, when jackpots get extremely large, they make the news, and more people will play. In fact, mathematically, it might actually make sense to play once the jackpot gets beyond a certain point.
A Powerball ticket costs $2, which means that once a jackpot is over $584 million approximately, the expected value of a ticket is more than the price of the ticket. That is, of course, assuming that there's only one winner and the jackpot isn't split. So for a lottery like Powerball, you want the odds to be long, but not too long, because you want it to roll over to build excitement. We can use the same technique to determine the number of possible five-card combinations out of a deck of cards.
Again, the order doesn't matter. So it would be 52 factorial divided by 47 factorial, and then take that number and divide it by 5 factorial. The number of possible five-card hands is 2,598,960. Significantly less than the number of ways to shuffle a deck. Of those possible hands, there are four that are considered a royal flush, the best hand in poker.
So the odds of getting a Royal Flush out of five cards is one in 649,740. However, the most popular poker game is Texas Hold'em, and players get seven cards to make a five-card hand, so the odds aren't quite the same. The math requires a few more steps, but the odds of a Royal Flush in Texas Hold'em is one in 30,940. Exactly 21 times better than getting it in just five cards.
So if you play a lot of poker, you might get a royal flush once or twice in your life, or quite possibly never. Permutations and combinations are something that most people never encounter as part of a basic mathematics education, but they really aren't that hard to understand. As I said before, it's all basic multiplication and division, albeit with very large numbers sometimes.
There are many resources online if it's something you want to learn more about. And it's an extremely handy thing to know if you want to be able to calculate the odds of something. The executive producer of Everything Everywhere Daily is Charles Daniel. The associate producers are Benji Long and Cameron Kiefer. I want to give a big shout out to everyone who supports the show over on Patreon, including the show's producers. Your support helps me put out a show every single day.
And also, Patreon is currently the only place where Everything Everywhere Daily merchandise is available to the top tier of supporters. If you'd like to talk to other listeners of the show and members of the Completionist Club, you can join the Everything Everywhere Daily Facebook group or Discord server. Links to everything are in the show notes.