I have $N$ cards with numbers written on it (from 1 to N, each card have only one number). Now, I divide them into $2$ halves. Next, I take one card from second half, one from first half and again, till no cards left. For example: Before shuffling: $1 2 3 4 5 6 7 8$ First half:$ 1 2 3 4$ Second half:$ 5 6 7 8$ After shuffling: $5 1 6 2 7 3 8 4$
I repeat shuffling M times. Now, someone is asking me to show him card with number K written on it. But I can't see the numbers, because the cards are faced down. How to tell on which position is card with number K written on it (for $N = 8$, $M = 1$ and $K = 3 $ the answer is 6, because after 1 shuffle, card with number 3 is on 6th position)?
I need a mathematical formula for this, because $N, M, K$ can be very large. If $N = 2n+1$, then first half contains $n$ cards and the second half contains $n+1$ cards.