Permutation { public static long factorial(final int n) { return PermutationUtil.factorial(n); } private  Permutation(); static long factorial(final int n); static List<T> permutation(final long no, final List<T> items); @SafeVarargs @SuppressWarnings("varargs") static Stream<Stream<T>> of(final T... items); static Stream<Stream<T>> of(final List<T> items);  }
@TestFactory Stream<DynamicTest> factorial() { return IntStream.range(0, 10) .mapToObj(i -> DynamicTest.dynamicTest("factorial(" + i + ")", () -> { assertEquals(Permutation.factorial(i), fac(i)); }) ); }
@Test void factorialTooLarge() { assertThrows(IllegalArgumentException.class, () -> { Permutation.factorial(21); }); }
@Test void factorialNegative() { assertThrows(IllegalArgumentException.class, () -> { Permutation.factorial(-1); }); }