Permutations Calculator

This program computes the exact count of all possible unique permutations (unique ordered sequences) of (N) distinct objects if taken in random groups of (R) at a time.

NOTE:
Since the program computes the EXACT value and performs all of its computations in arbitrary-precision, in some cases, the computed values may extend out to tens of thousands of digits and could possibly take up to several seconds to return the computed result.



N (0  to  9999) =            R (0  to  N) =        


The EXACT value of P(1,  1) is computed below and consists of 1 digit.





Permutations are ordered sequences, so the number of permutations means the number of unique ordered sequences in which (R) distinct items may be drawn from a total pool of (N) distinct items.  For example we could compute the total number of possible unique numbers we could create using 5 different digits from a total pool of 7 unique digits from which to choose.

All permutations are unique sequences or linear orders in which they can be arranged.  Any two sets containing the same (R) items, such as a sequence of letters, are considered identical only if all the letters in both sequences are in the same order as well.  The symbols are not limited only to letters, they can be numbers or any other unique items we wish to arrange in a sequence.

The letters EBCAD are not the same as EDCBA or any other combinations of the same characters.  That sequence of letters may be one out of many, but it is still unique among all the possible linear permutations of the unique letters A,B,C,D and E.  In permutations, the sequential order of the unique items is important.


Below is a listing of the PHP function at the heart of the above Permutations Calculator program.  It computes the total number of possible unique sequences (permutations) in arbitrary-precision, which could extend out to several thousands of digits.
/*
  ===========================================================================
  This function returns the EXACT count of unique permutations of (N) items
  that are possible, selected in random groups of (R) at a time.

  NOTE:  In permutations, the sequential order of the items in each group
         IS important.

  Author   : Jay Tanner - 2022
  Language : PHP v7.x
  ===========================================================================
*/

  function bcPerm_N_R ($N, $R)
{
  $P=1; for ($i=0;  $i < $R;  $i++) {$P = bcMul($P, $N-$i);}

  return $P;
}



Jay Tanner - 2022