### Question:
Library { public static BigInteger factorial(int n) { if (n < 0) throw new IllegalArgumentException("Factorial of negative number"); BigInteger prod = BigInteger.ONE; for (int i = 2; i <= n; i++) prod = prod.multiply(BigInteger.valueOf(i)); return prod; }  static String reverse(String s); static boolean isPalindrome(String s); static boolean isPalindrome(int x); static int sqrt(int x); static long sqrt(long x); static BigInteger sqrt(BigInteger x); static boolean isSquare(int x); static int pow(int x, int y); static int powMod(int x, int y, int m); static int reciprocalMod(int x, int m); static BigInteger factorial(int n); static BigInteger binomial(int n, int k); static int gcd(int x, int y); static boolean isPrime(int x); static boolean[] listPrimality(int n); static int[] listPrimes(int n); static int[] listSmallestPrimeFactors(int n); static int totient(int n); static int[] listTotients(int n); static boolean nextPermutation(int[] arr);  }### Answer:
@Test public void testFactorial() { assertEquals(new BigInteger("1"), Library.factorial(0)); assertEquals(new BigInteger("1"), Library.factorial(1)); assertEquals(new BigInteger("2"), Library.factorial(2)); assertEquals(new BigInteger("6"), Library.factorial(3)); assertEquals(new BigInteger("24"), Library.factorial(4)); assertEquals(new BigInteger("120"), Library.factorial(5)); assertEquals(new BigInteger("720"), Library.factorial(6)); assertEquals(new BigInteger("6227020800"), Library.factorial(13)); assertEquals(new BigInteger("51090942171709440000"), Library.factorial(21)); assertEquals(new BigInteger("265252859812191058636308480000000"), Library.factorial(30)); }
@Test(expected=IllegalArgumentException.class) public void testFactorialInvalid0() { Library.factorial(-1); }
@Test(expected=IllegalArgumentException.class) public void testFactorialInvalid1() { Library.factorial(-563); }
@Test(expected=IllegalArgumentException.class) public void testFactorialInvalid2() { Library.factorial(Integer.MIN_VALUE); }