public static double gamma(double z){
  if (z < 2.0) {
    return (Internalgamma(z));
  }
 else {
    double multiplier=Math.floor(z / 1.2);
    double remainder=z / multiplier;
    double coef1=Math.pow(2.0 * Math.PI,(0.5 * (1.0 - multiplier)));
    double coef2=Math.pow(multiplier,((multiplier * remainder) - 0.5));
    int N=(int)multiplier;
    double prod=1.0;
    for (int k=0; k < N; k++) {
      prod*=Internalgamma(remainder + ((double)k / multiplier));
    }
    return coef1 * coef2 * prod;
  }
}

public static double gamma ( double z ) { if ( z < 2.0 ) { return ( Internalgamma ( z ) ) ; } else { double multiplier = Math . floor ( z / 1.2 ) ; double remainder = z / multiplier ; double coef1 = Math . pow ( 2.0 * Math . PI , ( 0.5 * ( 1.0 - multiplier ) ) ) ; double coef2 = Math . pow ( multiplier , ( ( multiplier * remainder ) - 0.5 ) ) ; int N = ( int ) multiplier ; double prod = 1.0 ; for ( int k = 0 ; k < N ; k ++ ) { prod *= Internalgamma ( remainder + ( ( double ) k / multiplier ) ) ; } return coef1 * coef2 * prod ; } }
gamma function ( from dstat , used by permission ) . < p > calculates the value of gamma ( double z ) using handbook of mathematical functions ams 55 by abromowitz page 256 .
