求解java编程题,关于数组的题目,谢谢大神

编写求阶乘n!的函数。求从P个不同的数中选出Q个的组合数(P>=Q

 

package sample;

import java.math.BigInteger;

public class Combination2 {

	public static void main(String[] args) {
		int P = 30;
		int Q = 7;
		BigInteger Pf = BigInteger.ONE;
		for (int i = 1; i <= P; i++) {
			Pf = Pf.multiply(BigInteger.valueOf(i));
		}
		BigInteger Qf = BigInteger.ONE;
		for (int i = 1; i <= Q; i++) {
			Qf = Qf.multiply(BigInteger.valueOf(i));
		}
		BigInteger PQf = BigInteger.ONE;
		for (int i = 1; i <= P - Q; i++) {
			PQf = PQf.multiply(BigInteger.valueOf(i));
		}
		BigInteger PQr = Pf.divide(PQf);
		BigInteger Pcr = PQr.divide(Qf);
		System.out.println("C(" + P + "," + Q + ") = " + Pcr);
	}
}

C(30,7) = 2035800