Sum of combination

vegasal

Member
Hey everyone I’m looking for the math formula that will tell me exactly how many combinations can be made knowing a given sum i.e. the sum of 21 only one combination exists : 1-2-3-4-5-6 the sum of this is 21 the same is true for the sum of 279 only possible way to get that sum with 6 numbers from a pool of 49 unique numbers is with the combination 44-45-46-47-48-49 but what about the sum 133 or 150 which is the middle point between 21 and 279 and all others thanks for the help I want the math formula to figure them all out
 

PAB

Member
Hi vegasal,

Welcome to the board.
Below is the code (originally written by GillesD) to produce ALL the total combinations for each sum in a 649 Lotto.

Code:
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

Hope this Helps.
All the Best.
PAB
:wavey:
 

Bertil

Member
There is no need to calculate what has been tabulated by johnph77.
Go to Google and search for johnph77. Look for Lottery sums Frequency charts.

Bertil
 

Sidebar

Top