Java BigInteger Factorial factorial(BigInteger n)

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

Description

Naive (dumb) implementation of the factorial function.

License

Open Source License

Parameter

Parameter Description
n a parameter

Declaration

public static BigInteger factorial(BigInteger n) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;

public class Main {
    /**/*from  w  ww . j a v a  2 s  .c om*/
     * Naive (dumb) implementation of the factorial function.
     * @param n
     * @return
     */
    public static BigInteger factorial(BigInteger n) {
        if (n.equals(BigInteger.ONE)) {
            return BigInteger.ONE;
        }
        return n.multiply(factorial(n.subtract(BigInteger.ONE)));
    }
}

Related

  1. factorial(BigInteger n)
  2. factorial(BigInteger number)
  3. factorial(BigInteger originValue)