Welcome Guest
You last visited December 3, 2016, 8:36 am
All times shown are
Eastern Time (GMT-5:00)

# I have a math question

Topic closed. 22 replies. Last post 11 months ago by dr san.

 Page 2 of 2
New Member

Member #137795
January 12, 2013
24 Posts
Offline
 Posted: December 31, 2015, 2:34 pm - IP Logged

Pick 4,        1 to 38,      ? - ? - ? - ?,     = 73,815 combinations, is this correct ?

Yes.

Pick 4,        ?-?-?-?,    1 to 11 for first position,   5 to 24 for second position, 12 to 34 for third position, 19 to 37 for fourth position, = ? combinations.

is it 4006?

No.

it is 39,389

Hey, ya'll, Thanks for helping me out. I figured it out by cutting  and pasting with excel, took me 6 and a half hours, which is WHY I had to ask for help.

Looks like JADELottery had the correct answer to my question.    = 39,389,

later on when I am done with my little project, ill let you in on what i figured out and Ill ask for your opinions on my findings, Thanks again

.

The Quantum Master
West Concord, MN
United States
Member #21
December 7, 2001
3675 Posts
Offline
 Posted: December 31, 2015, 3:22 pm - IP Logged

Hey, ya'll, Thanks for helping me out. I figured it out by cutting  and pasting with excel, took me 6 and a half hours, which is WHY I had to ask for help.

Looks like JADELottery had the correct answer to my question.    = 39,389,

later on when I am done with my little project, ill let you in on what i figured out and Ill ask for your opinions on my findings, Thanks again

.

Thanks.

Here's the Excel VB code we used to generate the combinations.

____________________________________________________________________________________________________

Function Fact(ByVal n As Integer) As Double
On Error GoTo exitfunction
If (n <= 1) Then
Fact = 1
Else
Fact = n * Fact(n - 1)
End If
Exit Function
exitfunction:
Fact = -1
End Function

Function Perm(ByVal n As Integer, ByVal R As Integer) As Double
On Error GoTo exitfunction
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
Exit Function
exitfunction:
Perm = -1
End Function

Function Comb(ByVal n As Integer, ByVal R As Integer) As Double
On Error GoTo exitfunction
If (n < R) Then
Comb = 0
Else
Comb = Perm(n, R) / Fact(R)
End If
Exit Function
exitfunction:
Comb = -1
End Function

Function Cdist(ByVal n As Integer, ByVal R As Integer, ByVal C As Integer, ByVal Z As Integer) As Double
On Error GoTo exitfunction
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
Exit Function
exitfunction:
Cdist = -1
End Function

Function fColumnSum(ByVal n As Integer, ByVal R As Integer, ByVal Z As Integer) As Double
On Error GoTo exitfunction
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
Exit Function
exitfunction:
fColumnSum = -1
End Function

Function Index2Combin(ByVal n As Integer, ByVal R As Integer, ByVal i As Double) As String
On Error GoTo exitfunction
Dim a, b, Combination(), Z As Integer
Dim C, j As Double
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
Exit Function
exitfunction:
Index2Combin = "err"
End Function

Function Combin2Index(ByVal n As Integer, ByVal R As Integer, ByVal theRange As Range) As Double
On Error GoTo exitfunction
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
Exit Function
exitfunction:
Combin2Index = -1
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

Economy class
Belgium
Member #123700
February 27, 2012
4035 Posts
Offline
 Posted: December 31, 2015, 3:41 pm - IP Logged

I think that ranges are just too easy.

Do a mix such as:

1 3 5 7 8
6 7 8 9 10
9 15 16 17 20
30 34 38

This pure mixing, not by indeces and you can leave out the rotten apples!

I make this on LINK with groups:

Input: [[1, 3, 5, 7, 8], [6, 7, 8, 9, 10], [9, 15, 16, 17, 20], [30, 34, 38]].

Count of combinations: 315. Limit display: 3000.

1 10 15 30
1 10 15 34
1 10 15 38
1 10 16 30
1 10 16 34
1 10 16 38
1 10 17 30
1 10 17 34
1 10 17 38
1 10 20 30
1 10 20 34
1 10 20 38
1 6 15 30
1 6 15 34
1 6 15 38
1 6 16 30
1 6 16 34
1 6 16 38
1 6 17 30
1 6 17 34
1 6 17 38
1 6 20 30
1 6 20 34
1 6 20 38
1 6 9 30
1 6 9 34
1 6 9 38
1 7 15 30
1 7 15 34
1 7 15 38
1 7 16 30
1 7 16 34
1 7 16 38
1 7 17 30
1 7 17 34
1 7 17 38
1 7 20 30
1 7 20 34
1 7 20 38
1 7 9 30
1 7 9 34
1 7 9 38
1 8 15 30
1 8 15 34
1 8 15 38
1 8 16 30
1 8 16 34
1 8 16 38
1 8 17 30
1 8 17 34
1 8 17 38
1 8 20 30
1 8 20 34
1 8 20 38
1 8 9 30
1 8 9 34
1 8 9 38
1 9 10 30
1 9 10 34
1 9 10 38
1 9 15 30
1 9 15 34
1 9 15 38
1 9 16 30
1 9 16 34
1 9 16 38
1 9 17 30
1 9 17 34
1 9 17 38
1 9 20 30
1 9 20 34
1 9 20 38
3 10 15 30
3 10 15 34
3 10 15 38
3 10 16 30
3 10 16 34
3 10 16 38
3 10 17 30
3 10 17 34
3 10 17 38
3 10 20 30
3 10 20 34
3 10 20 38
3 6 15 30
3 6 15 34
3 6 15 38
3 6 16 30
3 6 16 34
3 6 16 38
3 6 17 30
3 6 17 34
3 6 17 38
3 6 20 30
3 6 20 34
3 6 20 38
3 6 9 30
3 6 9 34
3 6 9 38
3 7 15 30
3 7 15 34
3 7 15 38
3 7 16 30
3 7 16 34
3 7 16 38
3 7 17 30
3 7 17 34
3 7 17 38
3 7 20 30
3 7 20 34
3 7 20 38
3 7 9 30
3 7 9 34
3 7 9 38
3 8 15 30
3 8 15 34
3 8 15 38
3 8 16 30
3 8 16 34
3 8 16 38
3 8 17 30
3 8 17 34
3 8 17 38
3 8 20 30
3 8 20 34
3 8 20 38
3 8 9 30
3 8 9 34
3 8 9 38
3 9 10 30
3 9 10 34
3 9 10 38
3 9 15 30
3 9 15 34
3 9 15 38
3 9 16 30
3 9 16 34
3 9 16 38
3 9 17 30
3 9 17 34
3 9 17 38
3 9 20 30
3 9 20 34
3 9 20 38
5 10 15 30
5 10 15 34
5 10 15 38
5 10 16 30
5 10 16 34
5 10 16 38
5 10 17 30
5 10 17 34
5 10 17 38
5 10 20 30
5 10 20 34
5 10 20 38
5 6 15 30
5 6 15 34
5 6 15 38
5 6 16 30
5 6 16 34
5 6 16 38
5 6 17 30
5 6 17 34
5 6 17 38
5 6 20 30
5 6 20 34
5 6 20 38
5 6 9 30
5 6 9 34
5 6 9 38
5 7 15 30
5 7 15 34
5 7 15 38
5 7 16 30
5 7 16 34
5 7 16 38
5 7 17 30
5 7 17 34
5 7 17 38
5 7 20 30
5 7 20 34
5 7 20 38
5 7 9 30
5 7 9 34
5 7 9 38
5 8 15 30
5 8 15 34
5 8 15 38
5 8 16 30
5 8 16 34
5 8 16 38
5 8 17 30
5 8 17 34
5 8 17 38
5 8 20 30
5 8 20 34
5 8 20 38
5 8 9 30
5 8 9 34
5 8 9 38
5 9 10 30
5 9 10 34
5 9 10 38
5 9 15 30
5 9 15 34
5 9 15 38
5 9 16 30
5 9 16 34
5 9 16 38
5 9 17 30
5 9 17 34
5 9 17 38
5 9 20 30
5 9 20 34
5 9 20 38
6 7 15 30
6 7 15 34
6 7 15 38
6 7 16 30
6 7 16 34
6 7 16 38
6 7 17 30
6 7 17 34
6 7 17 38
6 7 20 30
6 7 20 34
6 7 20 38
6 7 9 30
6 7 9 34
6 7 9 38
6 8 15 30
6 8 15 34
6 8 15 38
6 8 16 30
6 8 16 34
6 8 16 38
6 8 17 30
6 8 17 34
6 8 17 38
6 8 20 30
6 8 20 34
6 8 20 38
6 8 9 30
6 8 9 34
6 8 9 38
7 10 15 30
7 10 15 34
7 10 15 38
7 10 16 30
7 10 16 34
7 10 16 38
7 10 17 30
7 10 17 34
7 10 17 38
7 10 20 30
7 10 20 34
7 10 20 38
7 8 15 30
7 8 15 34
7 8 15 38
7 8 16 30
7 8 16 34
7 8 16 38
7 8 17 30
7 8 17 34
7 8 17 38
7 8 20 30
7 8 20 34
7 8 20 38
7 8 9 30
7 8 9 34
7 8 9 38
7 9 10 30
7 9 10 34
7 9 10 38
7 9 15 30
7 9 15 34
7 9 15 38
7 9 16 30
7 9 16 34
7 9 16 38
7 9 17 30
7 9 17 34
7 9 17 38
7 9 20 30
7 9 20 34
7 9 20 38
8 10 15 30
8 10 15 34
8 10 15 38
8 10 16 30
8 10 16 34
8 10 16 38
8 10 17 30
8 10 17 34
8 10 17 38
8 10 20 30
8 10 20 34
8 10 20 38
8 9 10 30
8 9 10 34
8 9 10 38
8 9 15 30
8 9 15 34
8 9 15 38
8 9 16 30
8 9 16 34
8 9 16 38
8 9 17 30
8 9 17 34
8 9 17 38
8 9 20 30
8 9 20 34
8 9 20 38

New Member

Member #137795
January 12, 2013
24 Posts
Offline
 Posted: December 31, 2015, 4:12 pm - IP Logged

Thanks.

Here's the Excel VB code we used to generate the combinations.

____________________________________________________________________________________________________

Function Fact(ByVal n As Integer) As Double
On Error GoTo exitfunction
If (n <= 1) Then
Fact = 1
Else
Fact = n * Fact(n - 1)
End If
Exit Function
exitfunction:
Fact = -1
End Function

Function Perm(ByVal n As Integer, ByVal R As Integer) As Double
On Error GoTo exitfunction
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
Exit Function
exitfunction:
Perm = -1
End Function

Function Comb(ByVal n As Integer, ByVal R As Integer) As Double
On Error GoTo exitfunction
If (n < R) Then
Comb = 0
Else
Comb = Perm(n, R) / Fact(R)
End If
Exit Function
exitfunction:
Comb = -1
End Function

Function Cdist(ByVal n As Integer, ByVal R As Integer, ByVal C As Integer, ByVal Z As Integer) As Double
On Error GoTo exitfunction
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
Exit Function
exitfunction:
Cdist = -1
End Function

Function fColumnSum(ByVal n As Integer, ByVal R As Integer, ByVal Z As Integer) As Double
On Error GoTo exitfunction
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
Exit Function
exitfunction:
fColumnSum = -1
End Function

Function Index2Combin(ByVal n As Integer, ByVal R As Integer, ByVal i As Double) As String
On Error GoTo exitfunction
Dim a, b, Combination(), Z As Integer
Dim C, j As Double
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
Exit Function
exitfunction:
Index2Combin = "err"
End Function

Function Combin2Index(ByVal n As Integer, ByVal R As Integer, ByVal theRange As Range) As Double
On Error GoTo exitfunction
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
Exit Function
exitfunction:
Combin2Index = -1
End Function
____________________________________________________________________________________________________

LOL, that looks more complicated than Chinese to me.

Im still counting with my fingers.

The Quantum Master
West Concord, MN
United States
Member #21
December 7, 2001
3675 Posts
Offline
 Posted: December 31, 2015, 4:52 pm - IP Logged

LOL, that looks more complicated than Chinese to me.

Im still counting with my fingers.

Yep.

Hence, the files we made.

The files can be found here:

These have function description and usage in the Function Information tab.

 =Fact(N) Returns - - An integer - The factorial of N, mathematically written as ' N! ' - N! - N · (N - 1) · (N - 2) · … · 3 · 2 · 1 - 0! = 1 =Perm(N, R) Returns - - An integer - Using the Fact(N) function - The number of permutations in a pool of N numbers taken R at a time - (N! / (N - R)!) =Comb(N, R) Returns - - An integer - Using the Perm(N, R) and Fact(N) functions - The number of combinations in a pool of N numbers taken R at a time - (Perm(N, R) / Fact(R)) - (Perm(N, R) / R!) - ((N! / (N - R)!) / R!) - (N! / (R! · (N - R)!)) =Cdist(N, R, C, Z) Returns - - An integer - Using the Comb(N, R) function - The occurrence count of a number Z in a column C within a pool of N numbers taken R at a time - Comb((Z - 1), (C - 1)) · Comb((N - Z), (R - C)) - (((Z - 1)! / ((C - 1)! · (Z - 1 - (C - 1))!) · ((N - Z)! / ((R - C)! · (N - Z - (R - C))!))) - ((Z - 1)! · (N - Z)!) / ((C - 1)! · (Z - C)! · (R - C)! · (N - Z - R +C)!) =fColumnSum(N, R, Z) Returns - - An integer - Using the Cdist(N, R, C, Z) and Comb(N, R) functions - The sum of occurrence counts in the first column, 1, from the first number 1 to a number Z =Index2Combin(N, R, Index) Returns - - A string - Using the fColumnSum(N, R, Z) and Comb(N, R) functions - A Combination based on an Index in a pool of N numbers taken R at a time - 00's for an error condition =Combin2Index(N, R, Range) Returns - - An integer - Using the fColumnSum(N, R, Z) function - An Index value from a Combination within a pool of N numbers taken R at a time - A -1 for an error condition Variables and Array N - Pool Size, positive integer R - Pick Size, positive integer C - Column, positive integer Z - Number, positive integer Index - A positive integer index value within a combination of N numbers taken R at a time Range - An array of positive integer values in ascending order left to right; in a single row containing a combination of N numbers taken R at a time

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

New Mexico
United States
Member #86099
January 29, 2010
11115 Posts
Offline
 Posted: December 31, 2015, 7:02 pm - IP Logged

Yep.

Hence, the files we made.

The files can be found here:

These have function description and usage in the Function Information tab.

 =Fact(N) Returns - - An integer - The factorial of N, mathematically written as ' N! ' - N! - N · (N - 1) · (N - 2) · … · 3 · 2 · 1 - 0! = 1 =Perm(N, R) Returns - - An integer - Using the Fact(N) function - The number of permutations in a pool of N numbers taken R at a time - (N! / (N - R)!) =Comb(N, R) Returns - - An integer - Using the Perm(N, R) and Fact(N) functions - The number of combinations in a pool of N numbers taken R at a time - (Perm(N, R) / Fact(R)) - (Perm(N, R) / R!) - ((N! / (N - R)!) / R!) - (N! / (R! · (N - R)!)) =Cdist(N, R, C, Z) Returns - - An integer - Using the Comb(N, R) function - The occurrence count of a number Z in a column C within a pool of N numbers taken R at a time - Comb((Z - 1), (C - 1)) · Comb((N - Z), (R - C)) - (((Z - 1)! / ((C - 1)! · (Z - 1 - (C - 1))!) · ((N - Z)! / ((R - C)! · (N - Z - (R - C))!))) - ((Z - 1)! · (N - Z)!) / ((C - 1)! · (Z - C)! · (R - C)! · (N - Z - R +C)!) =fColumnSum(N, R, Z) Returns - - An integer - Using the Cdist(N, R, C, Z) and Comb(N, R) functions - The sum of occurrence counts in the first column, 1, from the first number 1 to a number Z =Index2Combin(N, R, Index) Returns - - A string - Using the fColumnSum(N, R, Z) and Comb(N, R) functions - A Combination based on an Index in a pool of N numbers taken R at a time - 00's for an error condition =Combin2Index(N, R, Range) Returns - - An integer - Using the fColumnSum(N, R, Z) function - An Index value from a Combination within a pool of N numbers taken R at a time - A -1 for an error condition Variables and Array N - Pool Size, positive integer R - Pick Size, positive integer C - Column, positive integer Z - Number, positive integer Index - A positive integer index value within a combination of N numbers taken R at a time Range - An array of positive integer values in ascending order left to right; in a single row containing a combination of N numbers taken R at a time

Impressive!

Happy new year Jade!

How about them cowboys!

Economy class
Belgium
Member #123700
February 27, 2012
4035 Posts
Offline
 Posted: January 1, 2016, 2:28 pm - IP Logged
bgonÃ§alves
Brasil
Member #92564
June 9, 2010
2122 Posts
Offline
 Posted: January 2, 2016, 5:52 am - IP Logged

Jaden, you can create a macro on the following criteria
Most = 02 = 01 Less Equal = 00 Always the last draw for the next Example
15 23 35 45 02 52                  02 code
05 18 29 38 48 59
already is 01 (less)
01 13 20 32 42 51 or other smaller or the larger numbers also

 Page 2 of 2