从N个数字中取出K个数字共有多少种取法Cn
n*(n-1)*(n-2)*(n-3)....(n-k+1)/1*2*3*...*k
用java代码:
public static int getCount(int n,int k)
{
int count = 1;
for(int i = 1;i<=k;i++)
{
count = count * (n-i+1)/i;
}
return count;
}
从N个数字中取出K个数字共有多少种取法Cn
n*(n-1)*(n-2)*(n-3)....(n-k+1)/1*2*3*...*k
用java代码:
public static int getCount(int n,int k)
{
int count = 1;
for(int i = 1;i<=k;i++)
{
count = count * (n-i+1)/i;
}
return count;
}