There are n numbers of cards labeled from 1 to n, each with an index from 1 to n counting from left to right, and the index changes as the number of cards reduces. To find the lucky card, do as follows:
- Keep the cards whose index modulus 3 is equal to 2 and discard all others.
- If there is more than 1 card left, repeat 1., else return the number labeled on the last card.
Limitation: 1 second of run time and 1023 MB of memory.
Input: n varies from 1 to 10^9