Class Factorial
java.lang.Object
de.tilman_neumann.jml.combinatorics.Factorial
public class Factorial
extends java.lang.Object
Implementations of the factorial function.
-
Constructor Summary
Constructors Constructor Description Factorial() -
Method Summary
Modifier and Type Method Description static java.math.BigIntegerfactorial(int n)Peter Luschny's swinging prime factorial algorithm, see http://luschny.de/math/factorial/SwingIntro.pdfstatic voidmain(java.lang.String[] args)Test.static java.math.BigIntegerwithStartResult(int n, int start, java.math.BigInteger startResult)Computes the factorial for non-negative integer arguments applying the simple product rule, but allowing for a previously computed start value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Factorial
public Factorial()
-
-
Method Details
-
withStartResult
public static java.math.BigInteger withStartResult(int n, int start, java.math.BigInteger startResult) throws java.lang.ArithmeticExceptionComputes the factorial for non-negative integer arguments applying the simple product rule, but allowing for a previously computed start value. Adapted from http://www.jonelo.de by Johann Nepomuk Loefflmann (jonelo@jonelo.de), published under GNU General Public License.- Parameters:
n- Argumentstart- Argument of the start resultstartResult- Factorial for start- Returns:
- n! if n is a non-negative integer
- Throws:
java.lang.ArithmeticException- if n is a negative integer
-
factorial
public static java.math.BigInteger factorial(int n) throws java.lang.ArithmeticExceptionPeter Luschny's swinging prime factorial algorithm, see http://luschny.de/math/factorial/SwingIntro.pdf- Parameters:
n-- Returns:
- n!
- Throws:
java.lang.ArithmeticException- if n is a negative integer
-
main
public static void main(java.lang.String[] args)Test.- Parameters:
args- Ignored.
-