public static BigInteger nCrBigInt(int n, int r) {
		if (r > n || r < 0) {
			return BigInteger.ZERO;
		}
		if (r == 0 || r == n) {
			return BigInteger.ONE;
		}
		if (r > n / 2) {
			// As Pascal's triangle is horizontally symmetric, use that property to reduce the for-loop below
			r = n - r;
		}
		
		BigInteger value = BigInteger.ONE;
		
		for (int i = 0; i < r; i++) {
			value = value.multiply(BigInteger.valueOf(n - i)).divide(BigInteger.valueOf(i + 1));
		}
		
		return value;
	}