Let denote the natural numbers. Compute the number of functions such that for all integers
Solution
By plugging in , we get that can be either . As is unrelated to all other values, we need to remember to multiply our answer by 2 at the end. Similarly, or 2 . Consider the graph . It is a binary tree rooted at -1 , and there is an edge , and a loop . Our first case is . Note that if satisfy , then . Otherwise, we would have , a contradiction as 3 is a nonresidue. So only the 8 leaves can take the value 1. This contributes . For , we can once again propagate down the tree. While it looks like we have 2 choices at each node (for the square roots), this is wrong, as if and , then is forced. Given this intuition, let denote the answer for a binary tree of height where the top is either -2 or 2. Therefore, . You can show the recurrence . This is because if the top is 2 , then we get a contribution of . If the top is -2 , then both entries below it must be 0 . After that, you can show that each of the remaining vertices can be either of 2 possible square roots. Therefore, we get the recurrence as claimed. One can compute that , so we get the final answer .