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
1,2,3,...,52
and now they are
1,27,2,28,...,26,52. Let's call this a perfect inshuffle.
If you repeat this inshuffling process, how many inshuffles 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, inshuffling 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 inshuffle yields 1,4,2,5,3.
(In reply to
re(5): Making a sequence (spoilers on the numbers) by GOM)
"But is there a formula?"
This raises a philosophical question. The formula is quoted as "the multiplicative order of 2 (mod n)". It happens that this function is not as well known as the sine function, or the ordinary log function, but it is a function. (As mentioned in my post, it bears definitional similarity to logarithms, and to invent a notation could just as easily say mod7logbase2(1).
The question is How can that be defined other than in a computer program? However, though say the sine function is defined in terms of right triangles, etc., it still needs to be computed via some sort of program or algorithm, such as
DECLARE FUNCTION s# (x#)
DEFDBL AZ
FOR arg = .1 TO 1 STEP .1
PRINT USING "#.############ "; s(arg); SIN(arg)
NEXT
END
FUNCTION s (x)
tot = x
term = x
n = 1
DO
n = n + 2
term = term * x * x / ((n  1) * n)
tot = tot + term
LOOP UNTIL ABS(term) < 1E12
s = tot
END FUNCTION
where the function is evaluated and compared to the builtin sine function of the Basic interpreter/compiler. The results do match:
0.099833418129 0.099833418129
0.198669333716 0.198669333716
0.295520210932 0.295520210932
0.389418347799 0.389418347799
0.479425545143 0.479425545143
0.564642480774 0.564642480774
0.644217695216 0.644217695216
0.717356099205 0.717356099205
0.783326917964 0.783326917964
The computer goes through a similar evaluation, though hidden from the user, in its evaluation of the sine function.
The case is probably even stronger for, say, logarithms, where there is not trianglemeasuring way of coming up with evaluations of the function.

Posted by Charlie
on 20040521 11:41:11 