# 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?

-
$n!\over (n-r)! r!$. For permutations you divide by $(n-r)!$, not $(r-1)!$. –  David Mitra Dec 16 '11 at 17:51
You could just look it up in Wikipedia. $\displaystyle n\mathrm{C}r =\frac{n!}{r!(n-r)!}$. –  Arturo Magidin Dec 16 '11 at 17:51
Alright, thank you guys so much! –  fr00ty_l00ps Dec 16 '11 at 17:53
@CodeAdmiral: Note: your formula for $n\mathrm{P}r$ is incorrect: it should be $n!$ divided by $(n-r)!$, not divided by $(r-1)!$. –  Arturo Magidin Dec 16 '11 at 18:12

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)!}$$

-
$\displaystyle n\mathrm{P}r =\frac{n!}{(n-r)!}$
$\displaystyle n\mathrm{C}r =\frac{n!}{r!(n-r)!}$