# CFLib.org – Common Function Library Project

## Combination(n, p)

##### Last updated July 18, 2001

Version: 1 | Requires: CF5 | Library: MathLib

Description:
Returns the Combination of n elements taken p at a time.

Return Values:
Returns a simple value

Example:

``````<CFSET n=13>
<CFSET p=2>
<CFOUTPUT>
Given n=13, p=2
Combination(n,p) is #Combination(n,p)#
</CFOUTPUT>``````

Parameters:

Name Description Required
n Any non-negative integer Yes
p any non-negative integer, <= n Yes

Full UDF Source:

``````/**
* Returns the Combination of n elements taken p at a time.
* This funciton requires the Permutation() and Factorial() functions from this library.
*
* @param n 	 Any non-negative integer
* @param p 	 any non-negative integer, <= n
* @return Returns a simple value
* @author Joel Cox (jlcox@goodyear.com)
* @version 1, July 18, 2001
*/
function Combination(n,p)
{
var RetVal = 0;
if (p GT n) {
RetVal = "undefined";
}
else
RetVal = Permutation(n,p) / Factorial(p);
Return RetVal;
}``````

date2ExcelDate
May 5, 2016

CapFirst
April 25, 2016