Combinations C(N, R) Calculator
PHP Program by Jay Tanner
Given a total pool of (N) distinct items, this program computes the total count of possible unique combinations of random groups of (R) taken at a time from that pool.  Any two groups containing the same (R) items are considered identical, regardless of the order in which the items are selected from the pool.

NOTE:
Since this program computes EXACT values 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.


1.E+0

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) at a time. 
/*
  ==========================================================================
  This function returns the exact number all possible random combinations
  of (R) distinct items from a total of pool of (N) items altogether. In
  combinations, only which items are in the selected group matters, the
  sequential order in which the items are selected does not matter.

  Rules: (N, R) are non-negative integers where R <= N

  Language : PHP
  ==========================================================================
*/

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

  for ($i=0;   $i < $j;   $i++)
      {
       $C = bcDiv(bcMul($C, $N-$i), $i+1);
      }
  return $C;
}


Jay Tanner - 2022