NCR

This algorithm finds all the possible combination of the value n and r.



									Private Shared Function Factorial(number As Integer) As Long
	If number < 0 Then
		Return -1 'Error
	End If

	Dim result As Long = 1

	For i As Integer = 1 To number
		result *= i
	Next

	Return result
End Function

Public Shared Function NCR(n As Integer, r As Integer) As Long
	Return Factorial(n) \ (Factorial(r) * Factorial(n - r))
End Function
								


Example

									Dim _NCR = NCR(5, 2)
								


Output

									10