Define as the product of all positive integers less than or equal to and relatively prime to . Compute the number of integers such that divides .
Solution
Note that, if is relatively prime to , there exists a unique such that . Hence, if , we can pair with its inverse to get a product of 1. If , then as well, and . Hence these can be paired up as well, giving products of -1. When , there is no such that and , so the total product is , where is the number of such that . For prime and positive integer , the number of solutions to is 2 if is odd, 4 if and , and 2 if . So, by Chinese remainder theorem, if we want the product to be -1, we need , or 4. We can also manually check the case to work. Counting the number of integers in the allowed range that are of one of these forms (or, easier, doing complementary counting), we get an answer of 30. (Note that this complicated argument basically reduces to wanting a primitive root.)