You have a deck of 52 cards - for convenience, number them 1 through 52. You cut the cards into two equal halves and shuffle them perfectly. That is, the cards were in the order
and now they are
1,27,2,28,...,26,52. Let's call this a perfect in-shuffle.
If you repeat this in-shuffling process, how many in-shuffles will it take for the deck to return to its initial ordering (taking for granted that the cards will eventually do so)?
How does the solution change if you have a deck of 64 cards, or 10, or in general, n cards? For odd integer values of n, in-shuffling will take 1,2,3,...,n to 1,(n+3)/2,2,(n+5)/2,...,n,(n+1)/2. For example, when n=5, the first in-shuffle yields 1,4,2,5,3.
I came up with a recursive definition for the successive positions of a card while we shuffle it, and when we get the same x value as the input we should be done, ofcourse we should maintain a count of how many times we recursed through the function, this is how I found out the answer for the initial case of 52 cards and it is 8:
if the initial position of a card is say 'p' then we can have this function, here 'n' is the total number of cards;
f(x) = f(2x - 1) if x <= n/2
f(x) = f(2x - n) if x > n/2
stop recursing if x = p (not for the first time)
we will run this function with any 'p' less than n and find out f(p), we stop when 2x-1 or 2x-n get equal to p, the number of recursions through this function to arrive at the same 'p' accounts for the number of shuffles needed to get the pack to the initial position. I tried this function manually for a number of two digit numbers, but all were even, i am sure this can be modified to make it work for odd numbers, also i observed the pattern that for power of 2 the exponent is the number of shuffles needed for example for 32 five shuffles, for 64 six shuffles and so on.