Kardi Teknomo
Kardi Teknomo Kardi Teknomo Kardi Teknomo
   
 
  Research
  Publications
  Tutorials
  Resume
  Personal
  Contact

 

Combination

By Kardi Teknomo, PhD.

<VB Tutorial | Contents | Previous | Next >

Here is an example of recusive procedure to calculate combination value (or called binomial coefficient)

1. Make a new project
2. To calculate combination, you can also use recursive procedure:

Function CombinationNCR(N As Long, r As Long) As Long
       ' nCr = n!/(r!*(n-r)!)
       ' to make it recursive:
       ' nCr = (n-r+1)/r * nCr-1
       ' where nC0 = 1
       Dim p As Long, i As Integer
       If r = 0 Or r = N Then
            CombinationNCR = 1
       Else
            CombinationNCR = CombinationNCR(N - 1, r) + _
            CombinationNCR(N - 1, r - 1)
       End If
End Function
             

3. Check how is it work.

<VB Tutorial | Contents | Previous | Next >

Rate this tutorial or give your comments about this tutorial

This tutorial is copyrighted.

Preferable reference for this tutorial is

Teknomo, Kardi. Visual Basic Tutorial . http:\\people.revoledu.com\kardi\ tutorial\VB

 

 

 

 
© 2007 Kardi Teknomo. All Rights Reserved.
Designed by CNV Media