title: Fast divisibility tests (by 2,3,4,5,.., 16)?
body: <p>What are the fastest divisibility tests? Say, given a little-endian architecture and a 32-bit signed integer: how to calculate very fast that a number is divisible by 2,3,4,5,... up to 16?</p>
  
  <p>WARNING: given code is EXAMPLE only. Every line is independent! Just obvious solution using modulo operation is slow on many processors, which don't have DIV hardware (like many ARMs). Some compilers are also cannot make such optimizations (say, if divisor is a function's argument or is dependent on something).</p>
  
  <pre><code>Divisible_by_1 = do();
  Divisible_by_2 = if (!(number &amp; 1)) do();
  Divisible_by_3 = ?
  Divisible_by_4 = ?
  Divisible_by_5 = ?
  Divisible_by_6 = ?
  Divisible_by_7 = ?
  Divisible_by_8 = ?
  Divisible_by_9 = ?
  Divisible_by_10 = ?
  Divisible_by_11 = ?
  Divisible_by_12 = ?
  Divisible_by_13 = ?
  Divisible_by_14 = ?
  Divisible_by_15 = ?
  Divisible_by_16 = if(!number &amp; 0x0000000F) do();
  </code></pre>
  
  <p>and special cases:</p>
  
  <pre><code>Divisible_by_2k = if(number &amp; (tk-1)) do();  //tk=2**k=(2*2*2*...) k times
  </code></pre>