title: Good hash function to partition an id using mod
body: <p>I have batch of ids I want to partition them with good liner spread function.<br>
  Ids do not contain timestamp and are really badly spread. I'm limited to few dumb <a href="https://www.w3schools.com/xml/xpath_operators.asp" rel="nofollow noreferrer">xpath operators</a>.</p>
  
  <p>Could you please propose better function to spread ids between 10 buckets?</p>
  
  <pre><code>public static void main(String[] args) {
      int[] buckets = new int[10];
      for (int i = 0; i &lt; 10; i++)
          buckets[i] = 0;
  
      for (int i = 0; i &lt; 1000; i++) {
          String id = format("130770%s0020", i);
          long l = parseLong(id);
          int partition = (int) f(l);
          buckets[partition] = buckets[partition] + 1;
      }
  
      for (int i = 0; i &lt; 10; i++)
          out.println(buckets[i]);
  }
  </code></pre>
  
  <p>Currently my best result is</p>
  
  <pre><code>private static long f(long l) {
      return l % 31 % 10;
  }
  </code></pre>
  
  <p>which gives  </p>
  
  <p>130 96 97 96 97 97 96 98 97 96</p>
  
  <p>can you propose better implementation?</p>
  
  <hr>
  
  <p>This is how code I'm editing looks like</p>
  
  <pre><code>&lt;rule id="trade_to_backet_4"&gt;
      &lt;forall var="trade_identifier" in="/eMxML/msml/trade/systemReference[1]/@reference"&gt;
          &lt;equal op1="translate($trade_identifier, translate($trade_identifier,'0123456789',''), '') mod 813 mod 10" op2="4"/&gt;
      &lt;/forall&gt;
  &lt;/rule&gt;
  </code></pre>