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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson