A good hash function needs to distribute the original data evenly into the hash array.
The original data is not really random, there may be some regularity,
For example, most are even, this time if the hash array capacity is even, it is easy to make the original data hash will not be evenly distributed.
For example 2 4 6 8 10 12 This 6 number, if the 6 to get the remainder of 2 4 0 2 4 0 will only get 3 hash values, the conflict will be many
If you get 2 4 6 1 3 5 for 7 gain, you get 6 hash values, no conflict
Similarly, if the data is a multiple of 3, and the hash array capacity is a multiple of 3, hash is also prone to conflict
Using a prime number reduces the probability of conflict
Reference
Http://www.xuebuyuan.com/2177964.html
http://www.vvbin.com/?p=376
Why do we want to use prime numbers (prime numbers) for modulo operations?