Know the circumstances in which (x) = (x * (x-1)/2 mod n is a full residual system of N (starting from 0 ), however, I didn't have a good idea for a YY lesson. I came back and saw the proof of Daniel. After studying it for a while, I finally understood it.

First, we can find that the period of f (x) is N or 2 * n, but when the period is 2 * n, the first N and the last n are symmetric, refer

Http://hi.baidu.com/findthegateopen/blog/item/03e5802e19f1ea301e3089f9.html

Therefore, in order to prove under what circumstances the f (x) % N is a completely residual system of N, we can assume that 0 <= I <j <n, and f (I) = f (J), that is, assume that f (x) % N is not the full remainder of N.

Available I * (I-1)/2 = J * (J-1)/2 mod N, finishing (J-I) * (I + J-1)/2 = 0 mod n

We can find that J-I is opposite to I + J-1

Discussion: If J-I is an even number

(1) If (J-I)/2 is an even number, because at this time I + J-1 is an odd number, n = S * 2 ^ K (s is an odd number, k> 0)

S is a factor of I + J-1, 2 ^ K is a factor of (J-I)/2, but when S = 1, n = 2 ^ K, and it must be a factor of (J-I)/2, because it cannot be a factor of I + J-1 (odd number), then J-I = 2 * n or J-I = 0, because 0 <= I <j <n, obviously not possible, S should be an odd number greater than 1

(2) If (J-I)/2 is odd, because I + J-1 is also odd, then n = p * q (p, q is odd ), P can be considered as a factor of (J-I)/2, and Q is a factor of I + J-1.

In summary, when n = S * 2 ^ K (S> 1 and S is odd, k> 0), or N = p * q (p, q is positive odd, f (x) % N cannot constitute the full residue of N.

The above two cases include all the situations where n = 2 ^ K (k> 0) is taken, so only when n = 2 ^ K (k> 0, f (x) % N is the full remainder of N

Summary:

At the beginning, I clarified the purpose of proof, but I did not expect to use the reverse proof method to identify conflicts with definitions to prove that my thinking ability is still poor.

Looking back at the entire process of proof, there are a lot of clever places, if not accumulated, it is difficult to think of, such as the expression of N and J-I and I + J-1 parity is opposite

In fact, all even numbers can be expressed as n = S * 2 ^ K (s is an odd number, k> 0). All odd numbers can be expressed as n = p * q (p, Q is an odd number)

In addition, in binary to determine whether a number is the power of 2, you can use X & (X-1) to determine, if the result is 0, it means yes, otherwise, it means not