CFLib.org – Common Function Library Project

Permutation(n, p)

Last updated July 18, 2001

author

Joel Cox

Version: 1 | Requires: CF5 | Library: MathLib

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

Return Values:
Returns a simple value.

Example:

<CFSET n=13>
  <CFSET p=4>
  <CFOUTPUT>
  Given n=13, p=4
  Permutation(n,p) is #Permutation(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 Permutation of n elements taken p at a time.
 * This funciton requires the Factorial() function 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.0, July 18, 2001 
 */
function Permutation(n,p)
{
  var RetVal = 0;
  if (p GT n) {
   RetVal = "undefined";
  }
  else
   RetVal = Factorial(n) / Factorial(n-p);  
  Return RetVal;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson