-1
$\begingroup$

I have found the following card trick:

  • Take a stack of n cards, with a known order.
  • Deal the cards from your hand onto the table like this: Card from the top, then card from the bottom, from the top, from the bottom, etc until the deck is depleted.
  • Keep dealing the cards like this. After a certain amount of deals (lets call that d) the original order will be restored.

I have made a table for n=1 through 25. The numbers for d are, consecutively: 1,2,2,3,3,5,6,4,4,9,6,11,10,9,14,5,5,12,18,12,10,7,12,23,21 I'm trying to find a pattern here, but I can't find one. My first thought was that after the same amount of deals as the amount of cards the sequence would repeat. Some seem to conform to n-1=d, but most don't. If you check for n-1=z*d, where z is an integer, most of them conform, but some don't.

Does anyone know what logic is hidden here? What is so special about n=16 and 17 (both just 5 deals required) and n=22 (just 7 deals required)?

$\endgroup$
  • $\begingroup$ From your table, there is a conjecture: with $2^n$ or $2^n+1$ cards, you get period $n+1$. But please specify your algorithm. The topmost card ends up topmost in the new pile, or at the bottom? For three cards 1-2-3 gives 2-3-1 or 1-3-2? According to your table, it should be 1-3-2. $\endgroup$ – Sebastian Goette Mar 18 '16 at 15:21
  • $\begingroup$ It's probably this one: oeis.org/A216066 $\endgroup$ – Wolfgang Mar 18 '16 at 15:42
4
$\begingroup$

In mathematical language, you're talking about the order of a certain permutation on $n$ letters, which can be easily computed using the cycle structure of the permutation.

Your sequence is OEIS sequence A216066, except that you have 1,2,2,3,... instead of 1,1,2,3,.... See in particular Robert Pfister's comment.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.