Line 10 and line 13 have some typo. Line 10 should be pw[i] = seed * pw[i - 1]; and Line 13 should be hs[i] = seed * hs[i - 1] + s[i];