1: int hash = 0; 2: int n = s.length(); 3: for (int i = 0; i < n; i++) 4: hash = g * hash + s.charAt(i); 5: // Version 4.0