1:  package de.luschny.math.factorial;
   2:   
   3:  import de.luschny.math.arithmetic.Xint;
   4:   
   5:  public class FactorialProductNaive implements IFactorialFunction
   6:  {
   7:   
   8:      public FactorialProductNaive()
   9:      {
  10:      }
  11:   
  12:      public String getName()
  13:      {
  14:          return "ProductNaive        ";
  15:      }
  16:   
  17:      public Xint factorial(int n)
  18:      {
  19:          if (n < 0)
  20:          {
  21:              throw new ArithmeticException("Factorial: n has to be >= 0, but was " + n);
  22:          }
  23:   
  24:          Xint nFact = Xint.ONE;
  25:   
  26:          for (int i = 2; i <= n; i++)
  27:          {
  28:              nFact = nFact.multiply(i);
  29:          }
  30:   
  31:          return nFact;
  32:      }
  33:   
  34:  } // endOfFactorialProductNaive