JackpotJockey
Member
Hello all,
Sorry if I jumped into a wrong forum, as this is more to do with math and code, than actual lottery. Quick scan of forum sections didn't reveal a spot suitable for my question. So I am posting here.
Lotto stuff has always been awesome for learning programming, which is what I am doing to get my limited and extremely rusty vb6 knowledge up to speed and (actually) learn VB.NET. Of course hoping for a side benefit of a win sure helps with staring at textbooks.
The curious thing I ran across is this:
Everyone claims, and I am in full mathematical agreement that in a 6/49 lottery the number of possible draws is :
49!/(6!*(49 - 6)!) or 13,983,816
Now, what I have done is try to code a small app that will generate all of them. Pretty useless but that is irelevant to the issue.
The way I worked it, and I am a newbie at programming, is to simply go :
1-2-3-4-5-6
1-2-3-4-5-7
1-2-3-4-5-8
1-2-3-4-5-9
1-2-3-4-5-10
.....
1-2-3-4-5-48
1-2-3-4-5-49
1-2-3-4-6-7
etc
Notice the switch once i hit 49 the previous number goes +1 and the following go from previous+1 to 49 and so on.
This is the visual basic code for those who know how to code and can read - be gentle I am newb at this:
Here is the kicker.
i have tested this algorythm for say small sets - like 5 out of 8, and it works absolutely perfectly. All combinations are indeed written, enumerated and unique - no repeats.
However, once I actually plug in the 6 out of 49 the total number of possible outcomes is well above 13 million. In fact it stops at 44-45-46-47-48-49 and enumerates it as 10,068,347,520.
What i dont get is, I know the math is right, I think, and I should be getting 13 million and change, but I also seem to have done the nested loop properly as it works perfectly for smaller sets that I can verify by hand.
Whats going on here? Is my code wrong, or is the real number of possible combinations far above 13 mil? Every smaller set test of this snippet I have done has never generated any duplicates and has indeed generated every combination.
Sorry if I jumped into a wrong forum, as this is more to do with math and code, than actual lottery. Quick scan of forum sections didn't reveal a spot suitable for my question. So I am posting here.
Lotto stuff has always been awesome for learning programming, which is what I am doing to get my limited and extremely rusty vb6 knowledge up to speed and (actually) learn VB.NET. Of course hoping for a side benefit of a win sure helps with staring at textbooks.
The curious thing I ran across is this:
Everyone claims, and I am in full mathematical agreement that in a 6/49 lottery the number of possible draws is :
49!/(6!*(49 - 6)!) or 13,983,816
Now, what I have done is try to code a small app that will generate all of them. Pretty useless but that is irelevant to the issue.
The way I worked it, and I am a newbie at programming, is to simply go :
1-2-3-4-5-6
1-2-3-4-5-7
1-2-3-4-5-8
1-2-3-4-5-9
1-2-3-4-5-10
.....
1-2-3-4-5-48
1-2-3-4-5-49
1-2-3-4-6-7
etc
Notice the switch once i hit 49 the previous number goes +1 and the following go from previous+1 to 49 and so on.
This is the visual basic code for those who know how to code and can read - be gentle I am newb at this:
Code:
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
Dim i As Long
Dim n6 As Integer
Dim n5 As Integer
Dim n4 As Integer
Dim n3 As Integer
Dim n2 As Integer
Dim n1 As Integer
For n1 = 1 To 43
For n2 = n1 + 1 To 44
For n3 = n2 + 1 To 45
For n4 = n3 + 1 To 46
For n5 = n4 + 1 To 47
For n6 = n5 + 1 To 48
i += 1
My.Application.DoEvents()
Label1.Text = CStr(i & vbTab & n1 & "," & n2 & "," & n3 & "," & n4 & "," & n5 & "," & n6)
FileOpen(1, "c:/enumerated.txt", OpenMode.Append)
PrintLine(1, i & "," & n1 & "," & n2 & "," & n3 & "," & n4 & "," & n5 & "," & n6)
FileClose(1)
Next n6
i += 1
My.Application.DoEvents()
FileOpen(1, "c:/enumerated.txt", OpenMode.Append)
PrintLine(1, i & "," & n1 & "," & n2 & "," & n3 & "," & n4 & "," & n5 & "," & n6)
FileClose(1)
Next n5
i += 1
My.Application.DoEvents()
FileOpen(1, "c:/enumerated.txt", OpenMode.Append)
PrintLine(1, i & "," & n1 & "," & n2 & "," & n3 & "," & n4 & "," & n5 & "," & n6)
FileClose(1)
Next n4
i += 1
My.Application.DoEvents()
FileOpen(1, "c:/enumerated.txt", OpenMode.Append)
PrintLine(1, i & "," & n1 & "," & n2 & "," & n3 & "," & n4 & "," & n5 & "," & n6)
FileClose(1)
Next n3
i += 1
My.Application.DoEvents()
FileOpen(1, "c:/enumerated.txt", OpenMode.Append)
PrintLine(1, i & "," & n1 & "," & n2 & "," & n3 & "," & n4 & "," & n5 & "," & n6)
FileClose(1)
Next n2
i += 1
My.Application.DoEvents()
FileOpen(1, "c:/enumerated.txt", OpenMode.Append)
PrintLine(1, i & "," & n1 & "," & n2 & "," & n3 & "," & n4 & "," & n5 & "," & n6)
FileClose(1)
Next n1
i += 1
My.Application.DoEvents()
FileOpen(1, "c:/enumerated.txt", OpenMode.Append)
PrintLine(1, i & "," & n1 & "," & n2 & "," & n3 & "," & n4 & "," & n5 & "," & n6)
FileClose(1)
Label1.Text = Label1.Text & vbtab & "done"
End Sub
Here is the kicker.
i have tested this algorythm for say small sets - like 5 out of 8, and it works absolutely perfectly. All combinations are indeed written, enumerated and unique - no repeats.
However, once I actually plug in the 6 out of 49 the total number of possible outcomes is well above 13 million. In fact it stops at 44-45-46-47-48-49 and enumerates it as 10,068,347,520.
What i dont get is, I know the math is right, I think, and I should be getting 13 million and change, but I also seem to have done the nested loop properly as it works perfectly for smaller sets that I can verify by hand.
Whats going on here? Is my code wrong, or is the real number of possible combinations far above 13 mil? Every smaller set test of this snippet I have done has never generated any duplicates and has indeed generated every combination.