Here you can find the source of Gamma(double z)
public static double Gamma(double z)
//package com.java2s; //License from project: LGPL public class Main { public static double Gamma(double z) { double total = 0.0; double step = (10 * z) / 1000; double t = 0; double r = z - 1; double last = Math.pow(t, r); for (t = step; t < 10 * z; t += step) { double next = Math.pow(t, r) * Exp(-t); total += TrapeziumArea(step, last, next); last = next;/*from w w w . jav a2 s .c o m*/ } return total; } /** * raises a number to the power e * * @param d * @return e^d */ public static double Exp(double d) { return Math.pow(Math.E, d); } /** * calculates the area of a trapezium * * @param width * the width accross the trapezium * @param a * side length of side a * @param b * side length of side b * @return the area of the trapezium */ public static double TrapeziumArea(double width, double a, double b) { return (0.5 * width * (a + b)); } }