public class Factorial
{
  public static int fac(int n)
  {
    int returnValue;
    if(0 > n)
    {
      throw new RuntimeException("cannot take factorial of negative number");
    }
    if(0 == n)
    {
      returnValue = 1;
    }
    else if(1 == n)
    {
      returnValue = 1;
    }
    else
    {
      returnValue = n * Factorial.fac(n-1);
    }

    return returnValue;
  } // public static int fac(int n)

} // public class Factorial

