Q:

Help with factorials, permutations, and combinations

I am an eighth grader in need of some help.  I was assigned a school project on making a java application that computes the total permutations of to given numbers where nPr and later on nCr.  I understand the equation for permutations is n! divided by (r-1)!, but what is the equation for combinations by the terms of n and r?

A:

One way to derive the formula from the number of permutations, $n\mathrm{P}r$, is the following:
To count the number of permutations of $r$ elements out of $n$, you can first select the $r$ elements, which can be done in $n\mathrm{C}r$ ways; and then you can order them, which can be done in $r\mathrm{P}r$ ways (you are now only ordering the $r$ elements you chose). That is,
$$n\mathrm{P}r = n\mathrm{C}r\times r\mathrm{P}r.$$
Since you already know that $n\mathrm{P}r = n!/(n-r)!$ and that $r\mathrm{P}r = r!$, then solving for $n\mathrm{C}r$ we get:
$$n\mathrm{C}r = \frac{n\mathrm{P}r}{r\mathrm{P}r} = \frac{n!}{r!(n-r)!}$$

