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.
(In reply to re(5): Making a sequence (spoilers on the numbers)
"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 mod7log-base-2(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#)
FOR arg = .1 TO 1 STEP .1
PRINT USING "#.############ "; s(arg); SIN(arg)
FUNCTION s (x)
tot = x
term = x
n = 1
n = n + 2
term = -term * x * x / ((n - 1) * n)
tot = tot + term
LOOP UNTIL ABS(term) < 1E-12
s = tot
where the function is evaluated and compared to the built-in sine function of the Basic interpreter/compiler. The results do match:
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 triangle-measuring way of coming up with evaluations of the function.
Posted by Charlie
on 2004-05-21 11:41:11