### Question:
Library { public static int[] listTotients(int n) { if (n < 0) throw new IllegalArgumentException("Negative array size"); int[] result = new int[n + 1]; for (int i = 0; i <= n; i++) result[i] = i; for (int i = 2; i <= n; i++) { if (result[i] == i) { for (int j = i; j <= n; j += i) result[j] -= result[j] / i; } } return result; }  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 testListTotients() { int[] totients = Library.listTotients(1000); for (int i = 1; i < totients.length; i++) assertEquals(Library.totient(i), totients[i]); }
@Test(expected=IllegalArgumentException.class) public void testListTotientsInvalid0() { Library.listTotients(-1); }
@Test(expected=IllegalArgumentException.class) public void testListTotientsInvalid1() { Library.listTotients(-3000); }