title: Very low cost hash function
body: <p>I need a hash function for a Look Up table, so that if my values are from 0 to N, I need a hash function that give me a value from 0 to n, being n &lt;&lt; N. Another piece of information is that I already know N in advance.</p>
  
  <p>I have been investigatinv about different low cost hash functions and I have found only this:</p>
  
  <pre><code>h = z mod n  range(z) - 0 to N, range(h) - 0 to n
  </code></pre>
  
  <p>My hash function needs to be implemented in HW, so it needs to have a very low cost. Can anyone recommend any other formula or algorithm apart from that simple thing?. When I say HW I mean a truly implementation in HW, and not instructions in a microprocessor.</p>
  
  <p>Thank you. </p>
  
  <p><strong>Update with the solution</strong></p>
  
  <p>Thanks for all the answer, I am not going to select a favourite one, because all of them are equally valid depending on the characteristics of the target application.</p>