Combinations Calculator
This program computes the total count of combinations of (N) distinct items if taken in random groups of (R) at a time from a total pool of (N) 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:
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 C(1, 1) is computed below and consists of 1 digit.


Jay Tanner - 2024

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 - 2024