Class Factorial
- java.lang.Object
-
- de.tilman_neumann.jml.combinatorics.Factorial
-
public class Factorial extends Object
Implementations of the factorial function.- Author:
- Tilman Neumann
-
-
Constructor Summary
Constructors Constructor Description Factorial()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigInteger
factorial(int n)
Peter Luschny's swinging prime factorial algorithm, see http://luschny.de/math/factorial/SwingIntro.pdfstatic void
main(String[] args)
Test.static BigInteger
withStartResult(int n, int start, BigInteger startResult)
Computes the factorial for non-negative integer arguments applying the simple product rule, but allowing for a previously computed start value.
-
-
-
Method Detail
-
withStartResult
public static BigInteger withStartResult(int n, int start, BigInteger startResult) throws ArithmeticException
Computes 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:
ArithmeticException
- if n is a negative integer
-
factorial
public static BigInteger factorial(int n) throws ArithmeticException
Peter Luschny's swinging prime factorial algorithm, see http://luschny.de/math/factorial/SwingIntro.pdf- Parameters:
n
-- Returns:
- n!
- Throws:
ArithmeticException
- if n is a negative integer
-
main
public static void main(String[] args)
Test.- Parameters:
args
- Ignored.
-
-