code: static int optimalNumOfHashFunctions(long n, long m) {
          // (m / n) * log(2), but avoid truncation due to division!
          return Math.max(1, (int) Math.round((double) m / n * Math.log(2)));
      }
docs: Computes the optimal k (number of hashes per element inserted in Bloom filter), given the
  expected insertions and total number of bits in the Bloom filter.
  
  See http://en.wikipedia.org/wiki/File:Bloom_filter_fp_probability.svg for the formula.
  
  @param n expected insertions (must be positive)
  @param m total number of bits in Bloom filter (must be positive)