Class Factorial


  • public class Factorial
    extends Object
    Implementations of the factorial function.
    Author:
    Tilman Neumann
    • Constructor Detail

      • Factorial

        public Factorial()
    • 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 - Argument
        start - Argument of the start result
        startResult - 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.