字符串哈希函数的有关问题

字符串哈希函数的问题是这样的int index0 //哈希表对应位置的下标while(*str){index31*index+*strstr+

字符串哈希函数的问题
是这样的
int index=0; //哈希表对应位置的下标
while(*str)
{
  index=31*index+*str;
  str++;
}
我想问这里的31有什么讲究么,是只能用31,还是说任意的质数都可以?

[解决办法]
不一定是31 但一般用质数 减少重复