Java Factorial factorial(int n)

Here you can find the source of factorial(int n)

Description

factorial

License

Open Source License

Declaration

public static double factorial(int n) 

Method Source Code

//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;
    }
}

Related

  1. factorial(int n)
  2. factorial(int n)
  3. factorial(int n)
  4. factorial(int n)
  5. factorial(int n)
  6. factorial(int n)
  7. factorial(int n)
  8. factorial(int number)
  9. factorial(int value)