我计算出一种方法的所有可能组合的最简单方法是什么?这是我正在尝试解决的示例类;
class Combinations {
public void generate()
{
final int TOTAL_A = 10;
final int TOTAL_B = 21; // TOTAL_B is used twice
final int TOTAL_C = 17;
final int TOTAL_Z = 20;
int count = 0;
for (int a = 0; a < TOTAL_A; a++)
{
for (int b = 0; b < TOTAL_B; b++)
{
for (int b_two = 0; b_two < TOTAL_B; b_two++)
{
for (int c = 0; c < TOTAL_C; c++)
{
for (int one = 0; one < TOTAL_Z; one++)
for (int two = one + 1; two < TOTAL_Z; two++)
for (int three = two + 1; three < TOTAL_Z; three++)
for (int four = three + 1; four < TOTAL_Z; four++)
for (int five = four + 1; five < TOTAL_Z; five++)
count++;
}
}
}
}
System.out.println("Total combinations: " + count);
}
}
在不必实际执行循环的情况下找出“计数”的方法是什么?