You roll multiple dice (with the same number of sides), what are the chances of getting matching sets?

For instance: You roll 10 dice that have 6 sides each. What is the chance that 2 of them are the same (does not matter the number, just that they are the same). What is the chance that 4 of them are the same?

For this I need something universal, a formula that can have varying numbers.

I got this formula from a friend, but it doesn't appear to be working correctly:

n = Total number of dice being rolled.

k = Number of dice that come up with desired result (the number of matching dice).

p = Chance of desired outcome occurring on one die, as a number between 0 and 1 (for six sided dice, this would be .166666).

n!*(p^k)*((1-p)^(n-k))

-----------------------

k!*(n-k)!