I think this is going to be a pretty complicated problem. I’ll put down some ideas and see what comes up.

Let X[sub]i,j,k[/sub] be the number of different ways to get *exactly* **i** different numbers when you throw a **j**-sided die **k** times. In the OP’s case, we are looking for X[sub]s,s,r[/sub]: the number of ways to get exactly s different numbers when throwing an s-sided die r times.

Once you have that, then the probability is X[sub]s,s,r[/sub] / s[sup]r[/sup].

Assume nice values for i,j,k, so:

0 < i <= j (have to roll at least 1 distinct number, and not more distinct numbers than there are sides)

j <= k (always roll at least as many times as there are sides, just to keep things nice)

We’ll try an example. How many ways to get exactly 4 different numbers from throwing a 6-sided die 8 times? X[sub]4,6,8[/sub]:

There are [sub]6[/sub]C[sub]4[/sub] different sets of 4 different numbers we could get. For each of these, there are 4[sup]8[/sup] different sets of 8 rolls. But those 4[sup]8[/sup] sets of rolls will contain some sets where only 3, 2, or 1 different numbers came up, so we need to get rid of those. How many of our 4[sup]8[/sup] had exactly 3 different numbers? X[sub]3,4,8[/sub]. Similarly for 2 and 1.

So X[sub]4,6,8[/sub] = [sub]6[/sub]C[sub]4[/sub] ( 4[sup]8[/sup] - X[sub]3,4,8[/sub] - X[sub]2,4,8[/sub] - X[sub]1,4,8[/sub] )

And (*I think*) in general:

X[sub]i,j,k[/sub] = [sub]j[/sub]C[sub]i[/sub] ( i[sup]k[/sup] - SUM[sub]z=1…i-1[/sub]X[sub]z,j,k[/sub] )

And we need a terminating condition for the recursion, so X[sub]1,j,k[/sub] = j.

Ok, now a really simple calculation to try this. Flip a coin twice; i.e., roll a 2-sided die twice. The outcomes are HH,HT,TH,TT, 2 of which have exactly 2 different values, so X[sub]2,2,2[/sub] should be 2.

X[sub]2,2,2[/sub] = [sub]2[/sub]C[sub]2[/sub] ( 2[sup]2[/sup] - X[sub]1,2,2[/sub] )

X[sub]2,2,2[/sub] = 1 ( 4 - 2 )

X[sub]2,2,2[/sub] = 2