For example, if n = 3, there are 10 possibilities:
111, 222, 333, 112, 113, 221, 223, 331, 332, 123
For n = 4, there are 35 possibilities;
For n = 5, there are 126 possibilities;
For n = 6, there are 446 possibilities;
For n = 7, there are 1569 possibilities;
I have found a way to calculate it, but it seems that I am going the long way. It goes like this:
For n = 5, find all the possible partitions, where each element is the length of equal digit sets in the number:
(5) -> 11111, 22222...
(4,1) -> 11112, 11113...
(3,2) -> 11122, 11133...
(3,1,1) -> 11123, 11124...
(2,2,1) -> 11223, 11224...
(2,1,1,1) -> 11234, 11235...
(1,1,1,1,1) -> 12345
Then, to calculate the number of combinations m of a given partition with k elements, I have found the following pattern:
$$
m = {n!\over(n-k)!\prod_{i=1}^n s_i!}
$$
Where $s_i$ is the number of sets of length i. Back to the example where n = 5, the number of combinations for each partition is:
(5) -> 1 set = 5!/(5-1)! = 5!/4! = 5
(4,1) -> 2 sets = 5!/(5-2)! = 5!/3! = 20
(3,2) -> 2 sets = 5!/(5-2)! = 5!/3! = 20
(3,1,1) -> 3 sets, 2 sets of length 1 = 5!/(5-3)!/2! = 5!/2!/2! = 30
(2,2,1) -> 3 sets, 2 sets of length 2 = 5!/(5-3)!/2! = 5!/2!/2! = 30
(2,1,1,1) -> 4 sets, 3 sets of length 1 = 5!/(5-4)!/3! = 5!/3! = 20
(1,1,1,1,1) -> 5 sets, 5 sets of length 1 = 5!/(5-5)!/5! = 5!/5! = 1
Finally, sum it all: 5+20+20+30+30+20+1 = 126
Is there an easier and more scalable way?