Select Page

Playing cards and number theory go together like young boys and bishops. Here’s an interesting application of mathematical cycles that involves card shuffling.

The type of shuffle in the photo above is called a ‘riffle shuffle’. I’m sure you’ve all seen it before. You split the deck into two parts and interlock the parts together by using a fanning motion. The way most people do it in general is quite randomly and haphazardly, which is fair enough because the idea is to mix the cards up as much as possible.

However, you can be a bit more precise. You can perform a ‘perfect’ riffle shuffle by splitting the deck into 2 exact halves (26 cards each) and interlocking the cards so that the cards from the 2 halves alternate into the final pile. To be a little more precise, if we call the two halves A and B, then we want to combine the cards so that every other card in the deck after the shuffle is from pile A.

Now, you may already have realised that there are exactly 2 ways of doing this. Suppose half A is the top half of the unshuffled deck and B is the bottom half. Then you can perform the shuffle with either:

1. The top card from B ending up on the top in the shuffled deck
2. The top card from A ending up on the top in the shuffled deck

Situation 1 is called ‘middle card top’, and 2 is called ‘top card top’, because these are the cards that will end up on the top of the shuffled deck.

It may seem like a trivial point, but magicians will know that this is not so! If we keep repeating the ‘middle card top’ shuffle, then we’d have to do it 52 times to return the deck to its original order. However, if we repeated the ‘top card top’ shuffle, we’d only have to repeat it 8 times to get back to the starting deck! This seems a little surprising!

Can we prove formally that this will happen every time without physically shuffling the cards and making a mess? Of course we can!

Middle card top

Let’s give each card in our unshuffled deck a number from 1-52 i.e. the top card is numbered 1, the second 2 and so on.

After a middle card top shuffle, the 27th card will be the top card in the shuffled deck. The 28th card will be in position 3, the 29th in position 5 etc. Therefore, the ordering of the shuffled deck after one iteration is:

27, 1, 28, 2, 29, 3, 30, 4, 31, 5, 32, 6, 33, 7, 34, 8, 35, 9, 36, 10, 37, 11, 38, 12, 39, 13, 40, 14, 41, 15, 42, 16, 43, 17, 44, 18, 45, 19, 46, 20, 47, 21, 48, 22, 49, 23, 50, 24, 51, 25, 52, 26.

The clever bit is that we don’t have to repeat this 52 times! We can see how the cards will cycle after shuffles by noticing that the 1st card becomes the 27th. The 27th card then becomes the 40th according to the ordering above. If we follow the above chain, we can write down the cycle in the following form:

(1, 27, 40, 20, 10, 5, 29, 41, 47, 50, 25, 39, 46, 23, 38, 19, 36, 18, 9, 31, 42, 21, 37, 45, 49, 51, 52, 26, 13, 33, 43, 48, 24, 12, 6, 3, 28, 14, 7, 30, 15, 34, 17, 35, 44, 22, 11, 32, 16, 8, 4, 2)

What does this tell us?

The first thing you should notice is that we have one big chain of numbers that loops around. The length of this loop is 52. This means that to get card 1 back in the top position, it has to travel through each of the other positions in the cycle. In other words, we have to repeat the shuffle exactly 52 times to get each of the cards back to their starting positions.

Now that we know what to do, it should be easier to look at the second shuffle.

Top card top

After one iteration of this shuffle, we get the ordering:

1, 27, 2, 28, 3, 29, 4, 30, 5, 31, 6, 32, 7, 33, 8, 34, 9, 35, 10, 36, 11, 37, 12, 38, 13, 39, 14, 40, 15, 41, 16, 42, 17, 43, 18, 44, 19, 45, 20, 46, 21, 47, 22, 48, 23, 49, 24, 50, 25, 51, 26, 52.

Writing this in cycle form, we can immediately see that there will be multiple cycles, because the first card always stays on top. Similarly, card 52 is still card 52 after an iteration of the shuffle. Writing out all of the cycles gives:

(1) (2,27,14,33,17,9,5,3) (4,28,40,46,49,25,13,7) (6,29,15,8,30,41,21,11) (10,31,16,34,43,22,37,19) (12,32,42,47,24,38,45,23) (18,35) (20,36,44,48,50,51,26,39) (52)

We can see that there are two cycles of length 1, one cycle of length 2 and six cycles of length 8. The lowest common multiple of 1, 2 and 8 is 8. Therefore, to reach the starting position, we only need to perform 8 shuffles of the top card top kind.

Remember folks, dexterity and maths are the key to becoming a successful close-up card trick expert!