Here you can find the source of factorial(int n)
public static double factorial(int n)
//package com.java2s; //License from project: Open Source License public class Main { public static double factorial(int n) { if (n < 0 || (n - (int) n) != 0) throw new IllegalArgumentException( "\nn must be a positive integer\nIs a Gamma funtion [gamma(x)] more appropriate?"); double f = 1.0D; for (int i = 1; i <= n; i++) f *= i;/*from w w w .ja v a 2s . co m*/ return f; } }