# Can You Count All The Ways To Shuffle A Deck Of Cards? We Bet You Can't

That's one. Image: Wirestock Creators/Shutterstock.com

Here’s a question: how long do you think it would take to shuffle a deck of cards into every order possible?

We’ll make it easier for you: we’ll assume you can shuffle cards at a super-human rate. Like, one completely new shuffle every second. Reckon you can do it?

What if we said you could do one thousand shuffles per second? In fact, what if we got the fastest computer in the world – it’s currently over in Japan fighting coronavirus, but we’re sure this is more important – to simulate shuffles at a rate of 415,530,000,000,000,000 per second? How long do you think it would take?

Here’s the thing: if you (or the Fugaku supercomputer) had started the challenge right at the first moment of the big bang, you still wouldn’t be finished. Not even close. Why? Well, it all comes down to an exclamation point – and the enormous power of numbers it can unlock.

A Factorial Problem

To understand what’s going on, let’s scale the problem down. How many ways are there to shuffle one card – say, the ace of spades?

It sounds like a trick question, but it’s not – it really is that easy. There’s one way to “shuffle” one card, and it’s to lay down that spadille on the table and declare job done.

Two cards is a little more difficult, but not hugely: there are two options, and they depend on which card you put down first.

When it comes to three cards, though, things get a little more interesting. Any one of the three can go first. Then for each of those, there are two options for the second card. Once those two slots are taken up, there’s only one choice for which comes out last.

When we count up all the possible permutations (that’s a legit math term, by the way, so feel free to whack it out at parties to impress your friends), we find there are six different ways to shuffle this three-card mini-deck.

Let’s break down what we’re doing here: with each card put down, we have one fewer degree of freedom for the shuffle. You can see it in the diagram – those six options are found by multiplying three, two, and one. When we multiply numbers like this, taking a value and multiplying it up by every positive whole number below it, mathematicians call it a factorial, and it’s written like this:

So: at a rate of one shuffle per second, so far we’ve taken one, two, and six seconds – hardly seems like a long time, right? But factorials can get really big, really quickly. By the time we’ve completed one suit, we already need nearly two centuries to lay out all possible shuffles.

Let’s add another suit. That’ll bring the shuffle time to, what, 400 years? 1,000?

Try 300 quintillion years.

To find out how many individual orders you can get using all 52 cards, we need to work out 52! – remember, that’s 52 factorial, not 52 in an excited voice. That comes to about 8 × 1067, or to put it in words, 80 thousand vigintillion different shuffles. That’s right: it’s a number so big you haven’t even heard of the word that’s used to describe it.

-

The Odds Of Winning

You may have heard the old line about being more likely to get struck by lightning than win the lottery, but have you ever wondered about the math behind it?

When it comes to the chances of getting struck by lightning, we have to rely on real-world data – according to the CDC, you have about a one in 500,000 chance of being hit by a bolt from the blue in any one year. But your odds of winning the lottery is all math – and a problem that harks directly back to the birth of the study of probability.

Back in the 16th century, math was quite a bit different from what we know today. For one thing, it was mostly geometry – people just weren’t that interested in questions that didn’t have real-world answers.

Then came Cardano.

Girolamo Cardano was born in Milan in 1501, and he was a mathematical trailblazer. He wrote the first book in Latin that dealt with algebra; he tackled cubic and quartic functions at a time when they were thought to be impossible. But more importantly, he was a recalcitrant gambler who relied on his math ability to beat his opponents and was known to get into knife fights with those he suspected of cheating. He, too, had a problem that required a real-world answer: how to win at gambling.

His book on the subject, the Liber de Ludo Aleae or Book on Games of Chance (it sounds classier in Latin, we admit), is basically a mathematical guide to gambling. While he didn’t use notation today’s mathematicians would recognize, he worked out answers to problems we now consider part of the field of combinatorics – the math of permutations (like the card shuffling problem from earlier), combinations (like permutations but with slightly different restrictions), and graphs, which are not what you think.

Much like Cardano himself, the first lottery in Italy was born in Milan, so there’s actually a non-zero chance (ha) that he could have played it at some point. Were he to calculate the odds of winning, however, he might decide against it: for a standard six-in-49 lottery, the chance of hitting the jackpot is one in 13,983,816 – nearly 28 times less than getting struck by lightning.

The math behind this answer is similar to the card shuffle problem – but not exactly the same. That’s because this is a combination, rather than permutation, problem: basically, the order doesn’t matter. If the winning numbers are one, four, five, 15, 23, and 38, it won’t matter if you picked them in the order one, 38, five, 23, four, 15.

This makes a big difference. At first, the solutions look the same: you have 49 options for your first number, 48 for the second, 47 for the third, and so on. But once we’ve chosen the sixth number, we stop. Instead of 49! choices, we only have 49 × 48 × 47 × 46 × 45 × 44, which we can write as

But we’re not finished yet: remember, order doesn’t matter. For each of those sets of six numbers we can choose, we need to figure out how many orders there are to pick them.

Sound familiar? It’s the card shuffling problem – but with just six cards. Instead of just one way of getting the winning combination out of those 10,068,347,520 possibilities, we have 6! ways. Our chances of winning have been increased by a factor of 720 – but as anybody who plays the lottery knows, they still ain’t good.

The Power of Factorials

Whoever chose the exclamation point to denote the factorial function had the right idea – it’s a magnificently mind-boggling way to figure out some pretty exciting results. And it doesn’t even need to be restricted to whole numbers: the gamma and pi functions are factorials that work outside the integers, and they live in a beautifully confusing region of number theory with a bunch of applications that make no sense in our puny three-dimensional world. There are double factorials, superfactorials, primorials, and much more – but for now, think on this: shuffle a deck of cards.

Lay them down on the table.

Congratulations: nobody has ever – ever – laid down a deck of cards in that order before.