How many ways are there to separate n numbers into 3 groups [closed]

I saw the following answer https://doubleroot.in/lessons/permutations-combinations/division-into-groups-1/ and it was almost the answer.

But I need to give an answer to the following exact question:

How many ways are there to separate the group {1, 2,...,n} into three groups when:

  • The order of the numbers in groups and the order of the groups is not important.
  • 1 or 2 of groups can be empty.

If I assume that the number of elements in each of the three groups is k1, k2 and k3 accordingly, then the number of ways to separate the n numbers into the groups is n!/(k1!k2!k3!) .

But i need the full calculation, including the count of the different k1,k2,k3 options.


Solution 1:

Each number can be placed in one of three groups, so there are $3^n$ ways of placing all the numbers if the groups were distinct.

In $3$ of those cases all the numbers are in the same group, so we should divide them by $3$. In all the rest there are $3!$ ways to permute the groups, so there are $$\frac 16(3^n-3)+1=\frac 16(3^n+3)$$ ways to divide the numbers into three groups.