Returns gamma value for a double in. - Java java.lang

Java examples for java.lang:Math Value

Description

Returns gamma value for a double in.

Demo Code


//package com.java2s;

public class Main {
    /**//from   w  w w .j a  v a  2  s.co  m
     * Returns gamma value for a double in.
     */
    public static double gammaFunction(double in) {
        if (in == 1.0) {
            return 1.0;
        }
        if (in == 0.5) {
            return Math.sqrt(Math.PI);
        }
        return (in - 1) * gammaFunction(in - 1);
    }
}

Related Tutorials