If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Permutation formula

Want to learn about the permutation formula and how to apply it to tricky problems? Explore this useful technique by solving seating arrangement problems with factorial notation and a general formula. This video also demonstrates the benefits of deductive reasoning over memorization.

Want to join the conversation?

  • piceratops seed style avatar for user Shaun Budhram
    If the number of chairs is indeed greater than the number of people, it breaks the generic formula of n! / (n-r)! because the denominator is a negative factorial (undefined). Is there an explanation for this case?
    (75 votes)
    Default Khan Academy avatar avatar for user
    • mr pants teal style avatar for user Cassie
      The general permutation can be thought of in two ways: who ends up seated in each chair, or which chair each person chooses to sit in. This is less important when the two groups are the same size, but much more important when one is limited. n and r are dictated by the limiting factor in question: which people get to be seated in each of the limited number of chairs (n = # of people, r = # of chairs), or which chairs do each of the limited number of people choose to sit in (n = # of chairs, r = number of people). In the permutation formula, n will always be the larger number of options and r the smaller.
      (75 votes)
  • blobby green style avatar for user Sameer Alam
    How many words can be formed using the word Pencil such that N is always next to E?
    (12 votes)
    Default Khan Academy avatar avatar for user
    • leafers ultimate style avatar for user Yoann Nouveau
      First let's think about it a bit, to figure out how many ways you can arrange "Pencil" with N and E always next to one another it's going to be all the different ways to arrange "pencil" as if "en" was a single letter and the same thing with "ne"

      1) How many ways can we arrange Pencil as if "en" was a single letter?
      5! = 120 ways, we have 5 things to arrange P c i l and "en"

      2) Now how many ways can we arrange Pencil as if "ne" was a single letter?
      Same thing, 5! = 120

      3) add them up
      5!+5!=120+120=240 ways !

      There we go ! There are 240 different ways to arrange "pencil" so that e and n are always next to each other.

      Now to dig in a little deeper what if we wanted "p e and n" to always be together ? Have a go at it before looking below :)




      With "e" and "n" we figured out that "en" and "ne" were the only two possible way to arrange them, and treated them as a single letter. But really we looked at all the different ways to arrange 2 items, and there was 2! ways of doing it, so 2 ways and "pencil" was treated as a 5 letters word. Finally we added them together to get our answer.
      Now we're doing it with 3 letters "p e and n" so there are 3! ways of arranging them, therefore 6 ways. And "pencil" just became a 4 letters word, so it has 4! ways of being arranged, therefore 24 ways.

      Let's take a second and figure out what 24 actually represents, 24 is the number of ways you can arrange "pencil" with "pen" being a single letter, but we got 6 of those (pen, nep, epn ...) so we need to multiply 24 by 6 to get our answer.
      24*6=144 ways to arrange pencil so that "p e and n" are always next to each other !

      Can you come up with a formula for a "n" long word where you want "x" items to be together ? :)
      (99 votes)
  • leafers ultimate style avatar for user Samuel L.
    Why is the factorial symbol an exclamation mark?
    (12 votes)
    Default Khan Academy avatar avatar for user
    • leaf blue style avatar for user Matthew Daly
      The notation (and the name "factorial") was chosen by Christian Kramp, a French mathematician who did much of the early work in combinatorics. He decided that a simple notation was important because the factorial was used so often in the formulas he was using.
      (39 votes)
  • male robot hal style avatar for user Aaroh Gokhale
    At he says that the formula is n!/(n-r)!, but in the first example there are 5 seats and 5 people; which is: 5!/(5-5)! which is 5!/0!. Anything divided by zero is undefined but the answer for the first one is 120. How is this possible?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user SULAGNA NANDI
    Would (n!)/((r-1)!) also work?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Tanner P
      No. The formula n!/(n-r)! works because n! gives the amount ways to arrange n object over n spaces. But since we are working with r spaces, there will be n-r spaces left over where we can’t arrange n. And (n-r)! gives all those arrangements that we will be missing, so we divide n! by that in order to eliminate them.

      (r-1)! gives you the number of arrangements over one less than the amount of spaces you have. The biggest problem with this is that we want to divide by the amount of arrangements we are missing, not the ones we have.
      (12 votes)
  • blobby green style avatar for user shane.orin.oconnor
    What if each person could also have an orientation? Say: 1 of 4 possibilities.
    I can reason that the answer for 5 people would be: (5*4) * (4*4) * (3*4) * (2*4) * (1*4) = 122,880.
    But I'm having expressing this with the proper syntax. Or am I heading in the wrong direction with trying to use factorial notation?
    (5 votes)
    Default Khan Academy avatar avatar for user
    • piceratops seed style avatar for user Chris O'Donnell
      The orientation doesn't depend on their seat or anyone else's orientation. So there would be 5! ways of arranging 5 people and for each of those 5 people, there would be 4 orientations. This means that there would be 4^5 ways of orienting everyone. Why? Because the first person has 4 orientations to pick from, the second person also has 4 orientations to pick from and so on. So we multiply 4*4*4*4*4 = 4^5. So the final result is 4^5 * 5! = 122,880.
      (6 votes)
  • blobby green style avatar for user David White
    Sal, can you explain, "you see that it's not some type of voodoo magic."?
    (7 votes)
    Default Khan Academy avatar avatar for user
  • male robot hal style avatar for user Arjun
    How would you go about finding permutations of a number, where some of the digits repeat? ex. 112233
    (2 votes)
    Default Khan Academy avatar avatar for user
    • mr pink red style avatar for user andrewp18
      We have 6 digits, and thus a preliminary count of 6!. However, note that several of these 6! configurations are not distinct. In particular, we have 2! ways to arrange the 1s, 2! ways to arrange the 2s, and 2! ways to arrange the 3s. Thus, we divide by those arrangements to account for the over-counting and our final answer is:
      6!/(2! • 2! • 2!) = 720/8 = 90
      Comment if you have questions!
      (5 votes)
  • blobby green style avatar for user Joseph Campos
    from a group of 9 different books 4 books are to be selected and arrange on a shelf.how many arrangement are possible
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user hanmeishu07
    why do we conduct multiplication instead of addition?
    (3 votes)
    Default Khan Academy avatar avatar for user

Video transcript

- [Voiceover] We know that if we had five people, let's say person A, person B, person C, person D, and person E, and we wanted to put them in five different, let's say, positions, or chairs, so position one, position two, position three, position four, and position five. If we wanted to count the number of scenarios, or we could say the number of permutations of putting these five people in these five chairs, we could say, well, we have five different ... If we seated people in order, which we might as well do, we could say, look, five different people could sit in chair one. So, for each of those scenarios, four different people could sit in chair two. Now, for each of these scenarios, now, so we have 20 scenarios. Five times four, we have 20 scenarios where we've seated seat one and seat two, how many people could we now seat in seat three for each of those 20 scenarios? Well, three people haven't sat down yet, so there's three possibilities there. So now, there's five times four times three scenarios for seating the first three people. How many people are left for seat four? Well, two people haven't sat down yet, so there's two possibilities. So now there's five times four times three times two scenarios of seating the first four seats. For each of those, how many possibilities are there for the fifth seat? Well, one. For each of those scenarios, we only have one person who hasn't sat down left, so there's one possibility. So the number of permutations, the number of ... Let me write this down. The number of permutations, permutations, of seating these five people in five chairs is five factorial. Five factorial, which is equal to five times four times three times two times one, which, of course, is equal to, let's see, 20 times six, which is equal to 120. We have already covered this in a previous video. But now let's do something maybe more interesting, or maybe you might find it less interesting. Let's say that we still have these five people, but we don't have as many chairs, so not everyone is going to be able to sit down. Let's say that we only have three chairs. We have chair one, we have chair two, and we have chair three. How many ways can you have five people, where only three of them are going to sit down in these three chairs, and we care which chair they sit in? I encourage you to pause the video and think about it. I am assuming you have had your go at it. Let's use the same logic. If we seat them in order, and we might as well, how many different people, if we haven't sat anyone yet, how many different people could sit in seat one? Well, we could have, if no one sat down, we had five different people, five different people could sit in seat one. For each of these scenarios where one person has already sat in seat one, how many people could sit in seat two? In each of these scenarios, if one person has sat down, there's four people left who haven't been seated, so four people could sit in seat two. So we have five times four scenarios where we've seated seats one and seat two. For each of those 20 scenarios, how many people could sit in seat three? Well, we haven't sat, we haven't seaten or sat three of the people yet, so for each of these 20, we could put three different people in seat three, so that gives us five times four times three scenarios. So this is equal to five times four times three scenarios, which is equal to, this is equal to 60. So there's 60 permutations of sitting five people in three chairs. Now this, and my brain, whenever I start to think in terms of permutations, I actually think in these ways. I just literally draw it out because I don't like formulas. I like to actually conceptualize and visualize what I'm doing. But you might say, hey, when we just did five different people in five different chairs, and we cared which seat they sit in, we had this five factorial. Factorial is kind of neat little operation there. How can I relate factorial to what we did just now? It looks like we kind of did factorial, but then we stopped. We stopped at, we didn't go times two times one. So one way to think about what we just did, is we just did five times four times three times two times one, but of course we actually didn't do the two times one, so you could take that and you could divide by two times one. If you did that, this two times one would cancel with that two times one and you'd be left with five times four times three. The whole reason I'm writing this way is that now I can write it in terms of factorial. I could write this as five factorial, five factorial, over two factorial, over two factorial. But then you might have the question where did this two come from? I have three seats. Where did this two come from? Well, think about it. I multiplied five times four times three, I kept going until I had that many seats, and then I didn't do the remainder. So the things that I left out, the things that I left out, that was essentially the number of people minus the number of chairs, so I was trying to put five things in three places. Five minus three, that gave me two left over. So I could write it like this. I could write it as five ... Let me use the same colors. I could write it as five factorial over, over five minus three, which of course is two, five minus three factorial. Another way of thinking about it, if we wanted to generalize, is if you're trying to figure out the number of permutations and there's a bunch of notations for writing this, if you're trying to figure out the number of permutations where you could put n people in r seats, or the number of permutations you could put n people in r seats, and there's other notations as well, well, this is just going to be n factorial over n minus r factorial. Here n was five, r was three. Five minus three is two. Now, you'll see this in a probability or a statistics class, and people might memorize this thing. It seems like this kind of daunting thing. I'll just tell you right now, the whole reason why I just showed this to you is so that you could connect it with what you might see in your textbook, or what you might see in a class, or when you see this type of formula, you see that it's not some type of voodoo magic. But I will tell that for me, personally, I never use this formula. I always reason it through, because if you just memorize the formula, you're always going, wait, does this formula apply there? What's n? What's r? But if you reason it through, it comes out of straight logic. You don't have to memorize anything. You don't feel like you're just memorizing without understanding. You're just using your deductive reasoning, your logic. That's especially valuable because as we'll see, not every scenario's going fit so cleanly into what we did. There might be some tweaks on this, where like maybe only person B likes sitting in one of the chairs, or who knows what it might be? Then your formula is going to be useless. So I like reasoning through it like this, but I just showed you this so that you could connect to it a formula that you might see in a lecture or in a class.