Java tutorial
//package com.java2s; public class Main { public static int expectedNumberOfSets(int setSize, int subSetSize) { if (setSize < subSetSize) { // Not enough sources throw new IllegalArgumentException( "Cannot create subsets of size " + subSetSize + " out of set of size " + setSize); } int expectedNumberOfSets = 1; int divider = 1; for (int i = 0; i < (setSize - subSetSize); i++) { expectedNumberOfSets *= setSize - i; divider *= i + 1; } return expectedNumberOfSets / divider; } }