[Math] How many ways are there to split $n$ students into groups of size $x$ OR $y$ ($50$ students into groups of $5$ or $6$)

combinationscombinatoricspermutations

How many ways are there to split $n$ students into groups of size $x$ OR $y$ ($50$ students into groups of $5$ or $6$)?

I understand there might not be an equation in general but is there an algorithm for finding the answer that I could follow?

Best Answer

If you specify how many of each size you want it is easy.

For example, splitting $50$ students into groups of sizes $5,5,5,5,6,6,6,6,6$ can be don in $\dfrac{30!}{5!^4 6!^5 4! 3!}$ ways.

In general if you have $n$ students and you split them into $a$ groups of size $x$ and $b$ groups of size $y$ there are $\frac{n!}{x!^ay!^b b!a!}$ ways to do it.

So one way to solve the problem is to calculate the number of ways for each possible way to add up to $n$ using groups of $x$ and $y$. Luckily the non-negative solutions to $ax+by=n$ can be found easily.