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 IntegerIf 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.