Welcome Guest
Log In | Register )
You last visited December 4, 2016, 3:15 pm
All times shown are
Eastern Time (GMT-5:00)

Formula

Topic closed. 4 replies. Last post 2 years ago by SergeM.

Page 1 of 1
PrintE-mailLink
godlike00's avatar - Lottery-023.jpg
New Member
Makati
Philippines
Member #159196
September 17, 2014
19 Posts
Offline
Posted: June 5, 2015, 5:40 am - IP Logged

Hello lottery mathematician. Could you help me on a formula where I can remove the number of combination for straight combination in Lotto

For example in a 6/42 Lotto game which has a Total Combinations of 5,245,786

If you eliminate 1,2,3,4,5,6 combination the total combinations would be 5,245,785

 

My purpose is to reduce the number of combination

 

Thank you very much

Do not cry for money it doesn't cry for you

    JADELottery's avatar - MeAtWork 03.PNG
    The Quantum Master
    West Concord, MN
    United States
    Member #21
    December 7, 2001
    3675 Posts
    Offline
    Posted: June 5, 2015, 11:47 am - IP Logged

    What you might need is a way to convert a combination to an index number and back.

    We have a Macro Excel sheet with a function for converting any combination to an index number and one for the reverse operation.

    For Excel 2003 and above
    http://www.jadexcode.com/Excel/CombinatorialIndex.xls
    ftp://www.jadexcode.com/Excel/CombinatorialIndex.xls

    For Excel 2007 and above
    http://www.jadexcode.com/Excel/CombinatorialIndex.xlsm
    ftp://www.jadexcode.com/Excel/CombinatorialIndex.xlsm

     

    Index Value ⇒Index to Combination ⇒Combination Separated ⇒Combination to Index
    101 02 03 04 05 061234561
    201 02 03 04 05 071234572
    301 02 03 04 05 081234583
    40001 02 03 04 17 3912341739400
    50001 02 03 04 22 2912342229500
    60001 02 03 04 28 3012342830600
    524578637 38 39 40 41 423738394041425245786
    497073916 18 26 27 33 401618262733404970739
    284570305 16 19 26 28 29516192628292845703
    56543201 11 17 21 30 3311117213033565432
    28527301 05 12 24 38 411512243841285273
    516005520 24 25 31 39 402024253139405160055
    353512707 15 21 25 28 29715212528293535127
    361237907 24 27 29 34 42724272934423612379
    230242404 11 17 32 41 42411173241422302424
    448767111 21 27 32 41 421121273241424487671
    375925508 13 14 17 28 36813141728363759255
    307327906 10 14 16 19 31610141619313073279
    73352801 22 31 35 40 4212231354042733528
    22924101 04 15 26 27 421415262742229241
    39733701 07 12 36 39 411712363941397337
    452082012 13 18 19 33 391213181933394520820
    361071607 23 32 34 36 41723323436413610716
    41689301 07 20 27 28 301720272830416893

     

     

    If you don't want to download the files, here is the VB Code for each of the functions.

    ____________________________________________________________________________________________________

     

    Function Fact(ByVal N As Integer) As Double
        If (N <= 1) Then
            Fact = 1
        Else
            Fact = N * Fact(N - 1)
        End If
    End Function

    Function Perm(ByVal N As Integer, ByVal R As Integer) As Double
        Dim a As Integer
        Dim b As Double
        b = 1
        If (N < R) Then
            Perm = 0
        Else
            For a = (N - (R - 1)) To N
                b = b * a
            Next a
            Perm = b
        End If
    End Function

    Function Comb(ByVal N As Integer, ByVal R As Integer) As Double
        If (N < R) Then
            Comb = 0
        Else
            Comb = Perm(N, R) / Fact(R)
        End If
    End Function

    Function Cdist(ByVal N As Integer, ByVal R As Integer, ByVal C As Integer, ByVal Z As Integer) As Double
        If ((Z < C) Or (Z > (N - (R - C))) Or (Z > N) Or (C > R) Or (N < 1) Or (R < 1) Or (C < 1) Or (Z < 1)) Then
            Cdist = 0
        Else
            Cdist = Comb((Z - 1), (C - 1)) * Comb((N - Z), (R - C))
        End If
    End Function

    Function fColumnSum(ByVal N As Integer, ByVal R As Integer, ByVal Z As Integer) As Double
        Dim a As Integer
        Dim ColumnSum As Double
        If (Z < 1) Then
            fColumnSum = 0
        ElseIf ((Z >= 1) And (Z < (N - (R - 1)))) Then
            ColumnSum = 0
            For a = 1 To Z
                ColumnSum = ColumnSum + Cdist(N, R, 1, a)
            Next a
            fColumnSum = ColumnSum
        ElseIf (Z >= (N - (R - 1))) Then
            fColumnSum = Comb(N, R)
        End If
    End Function

    Function Index2Combin(ByVal N As Integer, ByVal R As Integer, ByVal I As Long) As String
        Dim a, b, Combination(), Z As Integer
        Dim C, J As Long
        ReDim Combination(R)
        Dim tmpString, CombinFormat As String
        Dim NumberFound As Boolean
        tmpString = ""
        CombinFormat = ""
        C = Comb(N, R)
        J = I
        J = J - 1
        Z = 0
        b = Len(Format(N, "0"))
        For a = 1 To b
            CombinFormat = CombinFormat & "0"
        Next a
        For a = 1 To R
            If ((I >= 1) And (I <= C)) Then
                If (a = 1) Then
                    Combination(a) = 1
                Else
                    Combination(a) = Combination(a - 1) + 1
                End If
                NumberFound = False
                Do
                    Select Case (J - fColumnSum((N - Z), (R - (a - 1)), (Combination(a) - (Z + 1))))
                        Case Is < 0
                            Combination(a) = Combination(a) - 1
                            NumberFound = True
                        Case Is = 0
                            NumberFound = True
                        Case Is > 0
                            Combination(a) = Combination(a) + 1
                    End Select
                Loop Until NumberFound
                J = J - fColumnSum((N - Z), (R - (a - 1)), (Combination(a) - (Z + 1)))
                Z = Combination(a)
            Else
                Combination(a) = 0
            End If
            tmpString = tmpString & Format(Combination(a), CombinFormat)
            If (a < R) Then tmpString = tmpString & " "
        Next a
        Index2Combin = tmpString
    End Function

    Function Combin2Index(ByVal N As Integer, ByVal R As Integer, ByVal theRange As Range) As Double
        Dim a As Integer
        Dim fSum As Double
        Dim NotInAscendingOrder, NotInPool As Boolean
        NotInAscendingOrder = False
        NotInPool = False
        If ((theRange.Rows.Count <> 1) Or (theRange.Columns.Count <> R)) Then
            Combin2Index = -1
            Exit Function
        End If
        For a = 1 To R
            If (a < R) Then
                If (theRange.Cells(1, a) >= theRange.Cells(1, (a + 1))) Then
                    NotInAscendingOrder = True
                End If
            End If
            If ((theRange.Cells(1, a) < 1) Or (theRange.Cells(1, a) > N)) Then
                NotInPool = True
            End If
        Next a
        If (NotInAscendingOrder Or NotInPool) Then
            Combin2Index = -1
            Exit Function
        End If
        fSum = 1
        For a = 1 To R
            If (a = 1) Then
                fSum = fSum + fColumnSum(N, R, (theRange.Cells(1, 1) - 1))
            Else
                fSum = fSum + fColumnSum((N - theRange.Cells(1, (a - 1))), (R - (a - 1)), (theRange.Cells(1, a) - (theRange.Cells(1, (a - 1)) + 1)))
            End If
        Next a
        Combin2Index = fSum
    End Function

    ____________________________________________________________________________________________________

    Presented 'AS IS' and for Entertainment Purposes Only.
    Any gain or loss is your responsibility.
    Use at your own risk.

    Order is a Subset of Chaos
    Knowledge is Beyond Belief
    Wisdom is Not Censored
    Douglas Paul Smallish
    Jehocifer

      garyo1954's avatar - garyo
      Dallas, Texas
      United States
      Member #4549
      May 2, 2004
      1671 Posts
      Online
      Posted: June 5, 2015, 12:06 pm - IP Logged

      Hello lottery mathematician. Could you help me on a formula where I can remove the number of combination for straight combination in Lotto

      For example in a 6/42 Lotto game which has a Total Combinations of 5,245,786

      If you eliminate 1,2,3,4,5,6 combination the total combinations would be 5,245,785

       

      My purpose is to reduce the number of combination

       

      Thank you very much

      You have 37 combinations that meet your straight combination criteria.

       

      1, 2, 3, 4, 5, 6

      2, 3, 4, 5, 6, 7

      3, 4, 5, 6, 7, 8

      4, 5, 6, 7, 8, 9

      5, 6, 7, 8, 9, 10

      6, 7, 8, 9, 10, 11

      7, 8, 9, 10, 11, 12

      8, 9, 10, 11, 12, 13

      9, 10, 11, 12, 13, 14

      10, 11, 12, 13, 14, 15

      11, 12, 13, 14, 15, 16

      12, 13, 14, 15, 16, 17

      13, 14, 15, 16, 17, 18

      14, 15, 16, 17, 18, 19

      15, 16, 17, 18, 19, 20

      16, 17, 18, 19, 20, 21

      17, 18, 19, 20, 21, 22

      18, 19, 20, 21, 22, 23

      19, 20, 21, 22, 23, 24

      20, 21, 22, 23, 24, 25

      21, 22, 23, 24, 25, 26

      22, 23, 24, 25, 26, 27

      23, 24, 25, 26, 27, 28

      24, 25, 26, 27, 28, 29

      25, 26, 27, 28, 29, 30

      26, 27, 28, 29, 30, 31

      27, 28, 29, 30, 31, 32

      28, 29, 30, 31, 32, 33

      29, 30, 31, 32, 33, 34

      30, 31, 32, 33, 34, 35

      31, 32, 33, 34, 35, 36

      32, 33, 34, 35, 36, 37

      33, 34, 35, 36, 37, 38

      34, 35, 36, 37, 38, 39

      35, 36, 37, 38, 39, 40

      36, 37, 38, 39, 40, 41

      37, 38, 39, 40, 41, 42

      My greatest accomplishment is teaching cats about Vienna Sausage. When I need a friend, all I need do is walk outside, pop open a can, and every little critter in the neighborhood drops by to say "Hi!"

        JADELottery's avatar - MeAtWork 03.PNG
        The Quantum Master
        West Concord, MN
        United States
        Member #21
        December 7, 2001
        3675 Posts
        Offline
        Posted: June 5, 2015, 3:40 pm - IP Logged

        What you might need is a way to convert a combination to an index number and back.

        We have a Macro Excel sheet with a function for converting any combination to an index number and one for the reverse operation.

        For Excel 2003 and above
        http://www.jadexcode.com/Excel/CombinatorialIndex.xls
        ftp://www.jadexcode.com/Excel/CombinatorialIndex.xls

        For Excel 2007 and above
        http://www.jadexcode.com/Excel/CombinatorialIndex.xlsm
        ftp://www.jadexcode.com/Excel/CombinatorialIndex.xlsm

         

        Index Value ⇒Index to Combination ⇒Combination Separated ⇒Combination to Index
        101 02 03 04 05 061234561
        201 02 03 04 05 071234572
        301 02 03 04 05 081234583
        40001 02 03 04 17 3912341739400
        50001 02 03 04 22 2912342229500
        60001 02 03 04 28 3012342830600
        524578637 38 39 40 41 423738394041425245786
        497073916 18 26 27 33 401618262733404970739
        284570305 16 19 26 28 29516192628292845703
        56543201 11 17 21 30 3311117213033565432
        28527301 05 12 24 38 411512243841285273
        516005520 24 25 31 39 402024253139405160055
        353512707 15 21 25 28 29715212528293535127
        361237907 24 27 29 34 42724272934423612379
        230242404 11 17 32 41 42411173241422302424
        448767111 21 27 32 41 421121273241424487671
        375925508 13 14 17 28 36813141728363759255
        307327906 10 14 16 19 31610141619313073279
        73352801 22 31 35 40 4212231354042733528
        22924101 04 15 26 27 421415262742229241
        39733701 07 12 36 39 411712363941397337
        452082012 13 18 19 33 391213181933394520820
        361071607 23 32 34 36 41723323436413610716
        41689301 07 20 27 28 301720272830416893

         

         

        If you don't want to download the files, here is the VB Code for each of the functions.

        ____________________________________________________________________________________________________

         

        Function Fact(ByVal N As Integer) As Double
            If (N <= 1) Then
                Fact = 1
            Else
                Fact = N * Fact(N - 1)
            End If
        End Function

        Function Perm(ByVal N As Integer, ByVal R As Integer) As Double
            Dim a As Integer
            Dim b As Double
            b = 1
            If (N < R) Then
                Perm = 0
            Else
                For a = (N - (R - 1)) To N
                    b = b * a
                Next a
                Perm = b
            End If
        End Function

        Function Comb(ByVal N As Integer, ByVal R As Integer) As Double
            If (N < R) Then
                Comb = 0
            Else
                Comb = Perm(N, R) / Fact(R)
            End If
        End Function

        Function Cdist(ByVal N As Integer, ByVal R As Integer, ByVal C As Integer, ByVal Z As Integer) As Double
            If ((Z < C) Or (Z > (N - (R - C))) Or (Z > N) Or (C > R) Or (N < 1) Or (R < 1) Or (C < 1) Or (Z < 1)) Then
                Cdist = 0
            Else
                Cdist = Comb((Z - 1), (C - 1)) * Comb((N - Z), (R - C))
            End If
        End Function

        Function fColumnSum(ByVal N As Integer, ByVal R As Integer, ByVal Z As Integer) As Double
            Dim a As Integer
            Dim ColumnSum As Double
            If (Z < 1) Then
                fColumnSum = 0
            ElseIf ((Z >= 1) And (Z < (N - (R - 1)))) Then
                ColumnSum = 0
                For a = 1 To Z
                    ColumnSum = ColumnSum + Cdist(N, R, 1, a)
                Next a
                fColumnSum = ColumnSum
            ElseIf (Z >= (N - (R - 1))) Then
                fColumnSum = Comb(N, R)
            End If
        End Function

        Function Index2Combin(ByVal N As Integer, ByVal R As Integer, ByVal I As Long) As String
            Dim a, b, Combination(), Z As Integer
            Dim C, J As Long
            ReDim Combination(R)
            Dim tmpString, CombinFormat As String
            Dim NumberFound As Boolean
            tmpString = ""
            CombinFormat = ""
            C = Comb(N, R)
            J = I
            J = J - 1
            Z = 0
            b = Len(Format(N, "0"))
            For a = 1 To b
                CombinFormat = CombinFormat & "0"
            Next a
            For a = 1 To R
                If ((I >= 1) And (I <= C)) Then
                    If (a = 1) Then
                        Combination(a) = 1
                    Else
                        Combination(a) = Combination(a - 1) + 1
                    End If
                    NumberFound = False
                    Do
                        Select Case (J - fColumnSum((N - Z), (R - (a - 1)), (Combination(a) - (Z + 1))))
                            Case Is < 0
                                Combination(a) = Combination(a) - 1
                                NumberFound = True
                            Case Is = 0
                                NumberFound = True
                            Case Is > 0
                                Combination(a) = Combination(a) + 1
                        End Select
                    Loop Until NumberFound
                    J = J - fColumnSum((N - Z), (R - (a - 1)), (Combination(a) - (Z + 1)))
                    Z = Combination(a)
                Else
                    Combination(a) = 0
                End If
                tmpString = tmpString & Format(Combination(a), CombinFormat)
                If (a < R) Then tmpString = tmpString & " "
            Next a
            Index2Combin = tmpString
        End Function

        Function Combin2Index(ByVal N As Integer, ByVal R As Integer, ByVal theRange As Range) As Double
            Dim a As Integer
            Dim fSum As Double
            Dim NotInAscendingOrder, NotInPool As Boolean
            NotInAscendingOrder = False
            NotInPool = False
            If ((theRange.Rows.Count <> 1) Or (theRange.Columns.Count <> R)) Then
                Combin2Index = -1
                Exit Function
            End If
            For a = 1 To R
                If (a < R) Then
                    If (theRange.Cells(1, a) >= theRange.Cells(1, (a + 1))) Then
                        NotInAscendingOrder = True
                    End If
                End If
                If ((theRange.Cells(1, a) < 1) Or (theRange.Cells(1, a) > N)) Then
                    NotInPool = True
                End If
            Next a
            If (NotInAscendingOrder Or NotInPool) Then
                Combin2Index = -1
                Exit Function
            End If
            fSum = 1
            For a = 1 To R
                If (a = 1) Then
                    fSum = fSum + fColumnSum(N, R, (theRange.Cells(1, 1) - 1))
                Else
                    fSum = fSum + fColumnSum((N - theRange.Cells(1, (a - 1))), (R - (a - 1)), (theRange.Cells(1, a) - (theRange.Cells(1, (a - 1)) + 1)))
                End If
            Next a
            Combin2Index = fSum
        End Function

        ____________________________________________________________________________________________________

        Oops, correct http links.

        http://www.jadexcode.com/files/Excel/CombinatorialIndex.xls

        http://www.jadexcode.com/files/Excel/CombinatorialIndex.xlsm

        Presented 'AS IS' and for Entertainment Purposes Only.
        Any gain or loss is your responsibility.
        Use at your own risk.

        Order is a Subset of Chaos
        Knowledge is Beyond Belief
        Wisdom is Not Censored
        Douglas Paul Smallish
        Jehocifer

          SergeM's avatar - slow icon.png
          Economy class
          Belgium
          Member #123700
          February 27, 2012
          4035 Posts
          Offline
          Posted: June 5, 2015, 5:29 pm - IP Logged

          Write all combinations on paper. Strike through every second combination. Simulate a winning situation. Calculate the payout.