class Hypergeometric {

  public double dhyper(int x, int N, int M, int n) {
    /* It is not possible to draw more white balls
     * from an urn containing M white balls. Hence
     * the probability is 0.
     */
    if (x > M) return 0;

    /* Of course it is also not possible to draw
     * more white balls than the number of drawings.
     * The probability is 0.
     */
    if (x > n) return 0;

    /* Last but not least, it is also not possible
     * to draw more black balls than there are within
     * the urn.
     */
    if (n - x > N - M) return 0;

    return Math.exp(lNchooseK(M, x) + lNchooseK(N - M, n - x) - lNchooseK(N, n));
  }

  public  Hypergeometric();

}