CombinationSet { public int nbOfCombinations(int k) { if (k > set.size()) return 0; if (k == set.size()) return 1; long numerator = factorial(set.size()); long den1 = factorial(k); long den2 = factorial(set.size() - k); return (int) (numerator / (den1 * den2)); } CombinationSet(Set<? extends Object> set); int nbOfCombinations(int k); int nbOfCombinationsAbove(int k); List<Combination> getAllCombinationsOfNElements(int n); List<Combination> getAllCombinationsOfNOrMoreElements(int n); List<Combination> getAllCombinations(); long getTotalNb();  }
@Test public void testNbOfCombinations() { HashSet<Integer> set = new HashSet<Integer>(); set.add(1); set.add(2); set.add(3); CombinationSet combiSet = new CombinationSet(set); Assert.assertTrue(combiSet.nbOfCombinations(2) == 3); }