|
Sum for all combinations
Interesting information but you might prefer the sum of each possibility (from 21 to 279).
The following macro in VBA for Excel will generate a list of the number of combinations for all sums:
Option Explicit
Option Base 1
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer, F As Integer
Dim I As Integer, nSum(279) As Long
Sub SumAll()
Application.ScreenUpdating = False
Sheets("Sheet1").Select
Range("A2").Select
Range("A1").Value = "Sum"
Range("B1").Value = "# comb."
For I = 21 To 279
nSum(I) = 0
Next I
For A = 1 To 44
For B = A + 1 To 45
For C = B + 1 To 46
For D = C + 1 To 47
For E = D + 1 To 48
For F = E + 1 To 49
nSum(A + B + C + D + E + F) = nSum(A + B + C + D + E + F) + 1
Next F
Next E
Next D
Next C
Next B
Next A
For I = 21 To 279
ActiveCell.Value = I
ActiveCell.Offset(0, 1).Value = nSum(I)
ActiveCell.Offset(1, 0).Select
Next I
Application.ScreenUpdating = False
Range("A1").Select
End Sub
Then if you graph all this data, you will have a nice bell-shape curve for the number of combinations for each sum of 6 numbers for a 6/49 lotteriy.
|