Home > Software engineering >  A combination algorithm
A combination algorithm

Time:09-26

Have n number in which the number m out of a collection, can be repeated, how many kind of coldness, how much is this?
Such as 0, number three, take the combination of number 3
{0, 0)
{0, 1}
,0,2 {0}
,1,1 {0}
{0}
,2,2 {0}
,1,1 {1}
,1,2 {1}
,2,2 {1}
,2,2 {2}

CodePudding user response:

M a n a binary number

CodePudding user response:

In n different elements of the combination of r a be allowed to repeat, the combination of C (n + r - 1, r),

For no repeat the combination of C (n, r)=n!/(r! * (n - r)!

For n=r=3 allows the combination of repetition, on the type of n with n + r - 1 substitution:
(n + r - 1)!/(r! * (n - 1)!=5!/3! * 2!=4 * 5/2=10
  •  Tags:  
  • VBA
  • Related