// Compute C(m,n) for user-specified m and n 	
	
import java.util.*;	
	
public class Combination {	
	// main(): application entry point	
	public static void main(String[] args) {	
		// set input stream	
		Scanner stdin = new Scanner(System.in);	
	
		// prompt and extract user inputs	
		System.out.print("Enter number of distinct objects: ");	
		int m = stdin.nextInt();	
		System.out.print("Enter desired subset size: ");	
		int n = stdin.nextInt();	
	
		// compute the three needed factorials	
		int mFactorial = 1;	
		for (int i = 2; i <= m; ++i) {	
			mFactorial *= i;	
		}	
	
		int nFactorial = 1;	
		for (int i = 2; i <= n; ++i) {	
			nFactorial *= i;	
		}	
	
		int mDiffNFactorial = 1;	
		for (int i = 2; i <= m - n; ++i) {	
			mDiffNFactorial *= i;	
		}	
	
		// compute and displays combinations	
		int combinations = mFactorial	
			/ (mDiffNFactorial * nFactorial);	
	
		System.out.println("We can make " + combinations	
			+ " different combinations when choosing\n" + n 	
			+ " objects from " + m + " different objects\n");	
	}	
}	
