Combinations Calculator
This program computes the number of combinations of (N) distinct items taken in groups of (R) at a time from a total pool of (N) distinct items.  Any two groups containing the same (R) items are considered identical, regardless of the order in which the items were selected from the pool.

Note that in some cases, since we are working in arbitrary-precision, the number of combinations can be extremely large, up to many thousands of digits, so it could take several seconds to return the computed result.


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


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

Processing time was 0.000009 sec.


Jay Tanner - 2017

Combinations are mixtures of items, but in no particular order.  In each group of (R) items selected from a pool of (N) items, only which items make up the group is considered important, not the sequential order in which the items are selected for any group.

For example, ABCDEF is identical to DFACBE, BDFCEA, DABFCE and all other combinations (mixtures) of the same six letters.  The 5 cards making up a straight flush dealt in a poker game would be a good example of a combination where only which 5 cards are held is important, not the order in which they were dealt or received.

Below is a listing of the PHP function at the heart of the above Combinations Calculator program.  It computes the arbitrary-precision count of the total number of possible unique combinations of (N) items selected in groups of (R). 
/*
  ==========================================================================
  This function returns the total count of the number of possible unique
  combinations there are of N distinct items selected R at a time. The
  sequential order of the items in each group is NOT important.
  Only the collective content matters, regardless of order.

  Author   : Jay Tanner - 2014
  Language : PHP v5.x
  ==========================================================================
*/

  function bcComb_N_R ($N, $R)
{
  $C = 1;

  for ($i=0;   $i < $N-$R;   $i++)
      {
       $C = bcdiv(bcmul($C, $N-$i), $i+1);
      }
  return $C;
}



Jay Tanner - 2017