Let be a prime number. A flea is staying at point 0 of the real line. At each minute, the flea has three possibilities: to stay at its position, or to move by 1 to the left or to the right. After minutes, it wants to be at 0 again. Denote by the number of its strategies to do this (for example, : it may either stay at 0 for the entire time, or go to the left and then to the right, or go to the right and then to the left). Find modulo .
Solution
Solution 1. The answer is for for , and for . The case is already considered, let further . For a residue modulo denote by the number of Flea strategies for which she is at position modulo after minutes. Then . The natural recurrence is , where the indices are taken modulo . The idea is that modulo we have and . Indeed, for all strategies for minutes for which not all actions are the same, we may cyclically shift the actions, and so we partition such strategies onto groups by strategies which result with the same . Remaining three strategies correspond to . Thus, if we denote , we get a system of equations for all . It is not hard to solve this system (using the 3 -periodicity, for example). For we get , and for . Solution 2. Note that is the constant term of the Laurent polynomial (the moves to right, to left and staying are in natural correspondence with and 1.) Thus, working with power series over we get (using the notation for the coefficient of in ) and expanding we get the answer.