What’s the easiest way I’d work out the total possible combinations of a method? Here is an example class of what I’m trying to work out;
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);
}
}
What would be the way to figure out what “count” would be without having to actually do the loops?
Or if you want to choose from two different pools
B1andB2that have the same size:where
n choose kis defined as follows: