I know that I can get the number of permutations of items in a list without repetition using


How would I calculate the number of unique permutations when a given number of elements in n are repeated.

For example


I want the number of unique permutations of those 6 letters (using all 6 letters).


marked as duplicate by hardmath, Community Apr 26 '16 at 17:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Funny, I just made a code golf challenge with this exact premise! $\endgroup$ – qwr Apr 26 '16 at 17:16
  • $\begingroup$ @qwr Someone asked about it on stackoverflow, but they were trying to brute force it and ran out of memory. I thought surely there would be a question on math I could forward them to, but I couldn't find one. $\endgroup$ – Brendan Abel Apr 26 '16 at 17:18
  • $\begingroup$ How many are there for $AABB$? $\endgroup$ – Mambo Apr 26 '16 at 17:18
  • $\begingroup$ Searching questions tagged permutations with keyword repetition will find many other related posts. The Mississippi problem is something of a classic. $\endgroup$ – hardmath Apr 26 '16 at 17:23

There is a specific formula for such problems:

Permute all elements, and remove permutations of elements that are identical, viz.



Do you want the number of combinations of a fixed size? Or all sizes up to 6? If your problem is not too big, you can compute the number of combinations of each size separately and then add them up.

Also, do you care about order? For example, are AAB and ABA considered unique combinations? If these are not considered unique, consider trying stars-and-bars: How to use stars and bars (combinatorics)

  • $\begingroup$ Sorry, I just updated my question. I want permutations, not combinations. $\endgroup$ – Brendan Abel Apr 26 '16 at 17:16
  • $\begingroup$ the question asks about permutations, not combinations $\endgroup$ – qwr Apr 26 '16 at 17:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.