The VBA program needs to perform factorial for numbers exceeding 100. I would like to know if there is a data type that can handle that big of a number or if I will have to simplify the combination problem.
The equation used is a simple combination, which is n!/(r!*(n-r)!). Should I simplify this problem to get the result, or would a data type that can handle the number will be sufficient.
Private Sub CommandButton1_Click()
Dim j As Integer, c As Integer, b As Integer, p As Single, val As Long
c = 100
b = 105
p = 0.9
For j = c + 1 To b
val = fact(b) / (fact(j) * fact(b - j))
Cells(2, j - 100).value = val
Next j
End Sub
Public Function fact(x As Integer) As Long
Dim facts As Long, k As Integer
For k = 1 To x
facts = facts * x
Next k
Exit Function
End Function
I expect the output for the given combination, but the error shown is Run-Time error '6' Overflow.

Doublewill hold a100!, but with loss of precision. Starting from171!, not evenDoublewill be able to hold, not even with loss of precision.Double.