# [seqfan] a curious card trick

Max Alekseyev maxale at gmail.com
Tue Jun 2 09:24:32 CEST 2009

```SeqFans,

I'd like to share with you a nice triangular sequence arising from a
curious card trick.

Suppose that we have m (identical) cards and a row of n empty piles.
We deal m cards, one card into each pile circularly repeated:
one card to the 1st pile, one to the 2nd, ..., nth, 1st, 2nd, ...

Then we take all cards from the pile where the last card was dealt to
and deal them in a similar way: one card into 1st pile, one to the
2nd, etc.
and repeat the same procedure until we reach configuration with all m
cards in the first pile.

For example, for m=3 and n=3, this process can be viewed as a sequence
of configurations:
3* 0 0
1 1 1*
2* 1 0
1 2* 0
2 1* 0
3* 0 0
where * indicate a pile to deal on the next step.

It can be proved that starting with configuration
m* 0 0 ... 0
Define a(m,n) as the minimal (positive) number of steps required for m
cards and n piles to reach the initial configuration.
The above example tells that a(3,3)=5.

For 1 <= n <= m, we have the following table of values of a(m,n):

m=1: 1,
m=2: 1, 2,
m=3: 1, 4, 5,
m=4: 1, 3, 8, 9,
m=5: 1, 6, 24, 36, 37,
m=6: 1, 10, 9, 47, 85, 86,
m=7: 1, 12, 55, 125, 144, 231, 232,
m=8: 1, 4, 45, 181, 384, 511, 747, 748,
m=9: 1, 8, 22, 214, 613, 1097, 183, 931, 932,
m=10: 1, 18, 28, 54, 373, 837, 993, 1931, 2864, 2865,
...

This sequence is missing in the OEIS - I'm going to add it.
The second column is A002326(m-1).

Regards,
Max

```