OK. I don't have much time today but I was curious to see how quick these numbers grow.

I just used a simple loop assuming more than 1 member.

The numbers grow really quickly. For 2 members I get 5 dinners (you missed 1), for 3 members 15, for 10 members 678,570 and for 25 members 49,631,246,523,618,756,274 dinners

I used decimals to get all the digits.

Code:

Sub Dinners()
Dim bN() As Variant, DN As Variant
Dim j As Long, k As Long
Const N As Long = 25
ReDim bN(0 To N)
' calculate the Bell numbers
bN(0) = CDec(1)
bN(1) = CDec(1)
For j = 2 To N
For k = 0 To j - 1
bN(j) = bN(j) + bN(k) * Application.Combin(j - 1, k)
Next k
Next j
' D(n) = C(n,0) * B(n) + C(n,1) * B(n-1) + C(n,2) * B(n-2) ...
' calculate the number of dinners
For k = 0 To N
DN = DN + Application.Combin(N, k) * bN(N - k)
Next k
Debug.Print Format(DN, "#,##0")
End Sub

In conclusion

It's easy to see if the solution is good. You just gather 25 people in a room, try all the dinner combinations and see if it checks.

## Like this thread? Share it with others