T

Given the digit (0, 1,3,5, 6), how many diff. 4 digit numbers can be made that aredivisible by 4 if repetitions are alloweed? If repetitions are not allowed?

7 Answers
(hint: a number is divisible by 4 if the last two digits form a number that is divisible by 4 or ends in 00) ans: (a.) 125 (b.) 24 ,.,.,is it right,., can you help me how to come up with that answer.?
I

Hi,
There are totally 100 such integers (4 digit numbers, where 1st digit is nonzero and is one of 1,3,5,6 and the 2nd through 4th digit are one of 0,1,3,5,6 and which are exacrly divisible by 4).
starting with 1000 and ending 6660.
The values are as under:
1000
1016
1036
1056
1060
1100
1116
1136
1156
1160
1300
1316
1336
1356
1360
1500
1516
1536
1556
1560
1600
1616
1636
1656
1660
3000
3016
3036
3056
3060
3100
3116
3136
3156
3160
3300
3316
3336
3356
3360
3500
3516
3536
3556
3560
3600
3616
3636
3656
3660
5000
5016
5036
5056
5060
5100
5116
5136
5156
5160
5300
5316
5336
5356
5360
5500
5516
5536
5556
5560
5600
5616
5636
5656
5660
6000
6016
6036
6056
6060
6100
6116
6136
6156
6160
6300
6316
6336
6356
6360
6500
6516
6536
6556
6560
6600
6616
6636
6656
6660

The macro that got these is as under, embed it into xl and run it.
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+j
'
For i = 1000 To 9999
DoEvents
a$ = Trim(Str(i))
one = Left(a$, 1)
two = Mid(a$, 2, 1)
three = Mid(a$, 3, 1)
four = Right(a$, 1)
myflag = 0
If Val(one) = 1 Or Val(one) = 3 Or Val(one) = 5 Or Val(one) = 6 Then
myflag = myflag + 1
Else
myflag = myflag - 1
End If
If Val(two) = 0 Or Val(two) = 1 Or Val(two) = 3 Or Val(two) = 5 Or Val(two) = 6 Then
myflag = myflag + 1
Else
myflag = myflag - 1
End If
If Val(three) = 0 Or Val(three) = 1 Or Val(three) = 3 Or Val(three) = 5 Or Val(three) = 6 Then
myflag = myflag + 1
Else
myflag = myflag - 1
End If
If Val(four) = 0 Or Val(four) = 1 Or Val(four) = 3 Or Val(four) = 5 Or Val(four) = 6 Then
myflag = myflag + 1
Else
myflag = myflag - 1
End If
If myflag = 4 Then
r = i Mod 4
If r = 0 Then
j = j + 1
Cells(j, 1) = i
End If
End If
Next i
MsgBox "Done"
End Sub

...
I

The above 100 are with repetitions allowed.

Now if repetitions are not allowed.
There are only 18!
1036
1056
1356
1360
1536
1560
3016
3056
3156
3160
3516
3560
5016
5036
5136
5160
5316
5360

The macro used is as under in xl module.
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+j
'
For i = 1000 To 9999
DoEvents
a$ = Trim(Str(i))
one = Left(a$, 1)
two = Mid(a$, 2, 1)
three = Mid(a$, 3, 1)
four = Right(a$, 1)
myflag = 0
If Val(one) = 1 Or Val(one) = 3 Or Val(one) = 5 Or Val(one) = 6 Then
myflag = myflag + 1
Else
myflag = myflag - 1
End If
If Val(two) = 0 Or Val(two) = 1 Or Val(two) = 3 Or Val(two) = 5 Or Val(two) = 6 Then
myflag = myflag + 1
Else
myflag = myflag - 1
End If
If Val(three) = 0 Or Val(three) = 1 Or Val(three) = 3 Or Val(three) = 5 Or Val(three) = 6 Then
myflag = myflag + 1
Else
myflag = myflag - 1
End If
If Val(four) = 0 Or Val(four) = 1 Or Val(four) = 3 Or Val(four) = 5 Or Val(four) = 6 Then
myflag = myflag + 1
Else
myflag = myflag - 1
End If

'the rule for checking repetition
If Val(one) = Val(two) Or _
Val(one) = Val(three) Or _
Val(one) = Val(four) Then
myflag = 0
End If
If Val(two) = Val(three) Or _
Val(two) = Val(four) Then
myflag = 0
End If
If Val(three) = Val(four) Then
myflag = 0
End If

If myflag = 4 Then
r = i Mod 4
If r = 0 Then
j = j + 1
Cells(j, 1) = i
End If
End If
Next i
MsgBox "Done"
End Sub

Comment the "rule" to get the inclusive values again (100 of them). ...

A

First, if repetetion is allowed:
Given digits are 0, 1, 3, 5 and 6.
If we group these numbers into groups of 2, then we can get the following numbers:
00, 01, 03, 05, 06, 10, 11, 13, 15, 16, 30, 31, 33, 35, 36, 50, 51, 53, 55, 56, 60, 61, 63, 65, 66.
Out of these numbers, the numbers that are divisible by 4 are 00, 16, 36, 56 and 60. Thus there are 5 two digit numbers divisible by 4 from the above given digits.
All the numbers that end in 00, 16, 36, 56 or 60 are divisible by 4.
When the last two digits of a number are 0 and 0, then there can be 5 * 4 = 20 such numbers.
When the last two digits of a number are 1 and 6, then there can be 5 * 4 = 20 such numbers.
When the last two digits of a number are 3 and 6, then there can be 5 * 4 = 20 such numbers.
When the last two digits of a number are 5 and 6, then there can be 5 * 4 = 20 such numbers.
When the last two digits of a number are 6 and 0, then there can be 5 * 4 = 20 such numbers.
Therefore the total number of four digit numbers that can be formed from the digits 0, 1, 3, 5 and 6 that are divisible by 4 are 20 * 5 = 100 when repetetion is allowed

Then, if repetetion is not allowed:
When the last two digits of a number are 1 and 6, then there can be 2 * 2 = 4 such numbers.
When the last two digits of a number are 3 and 6, then there can be 2 * 2 = 4 such numbers.
When the last two digits of a number are 5 and 6, then there can be 2 * 2 = 4 such numbers.
When the last two digits of a number are 6 and 0, then there can be 3 * 2 = 6 such numbers.
Therefore the total number of four digit numbers that can be formed from the digits 0, 1, 3, 5 and 6 that are divisible by 4 are 4 * 3 + 6 = 18 when repetetion is not allowed.

...
H

If repetitions are allowed, then there are 5*4*3*2 = 120 different 4-digit numbers possible. Of these 120 different numbers the only ones divisble by 4 are those where the last 2 digits are 00, 16, 36, 56, or 60 (per the hint on divisibility by 4). That means you only have the first two digits to play with now. So you have 5*5 = 25 possibilities for each ending 2-digit sequence. Because there are 5 of these (i.e., 00, 16, 36, 56, and 60) you have 5*25=125 different possibilities of a 4-digit number that is divisible by 4.

Without repetition there are Permut(5,4) = (5*4*3*2*1)/(4*3*2*1) = 5 different 4-digit numbers for each of the 5 different possibilities of the first digit. Thus there are 5*5 = 25 different 4-digit numbers you can make out of the integers in question (without any of the digits being used more than once). If you reverse this idea so that the first and second digit are the 16, 36, 56, or 60 (reversed to be 61, 63, 65, and 06 [note that 00 has been removed as a potential base due to repetition of 0]) then you have 3 remaining integers to choose the remaining 2 digits from. Thus you have (3*2)=6 possibilities for each of the 4 bases. Therefore, without repetition, you have 6*4=24 different 4-digit numbers that can be made from (0,1,3,5,6) without repeating any of the digits.

...
H

If repetitions are allowed, then there are 5*4*3*2 = 120 different 4-digit numbers possible. Of these 120 different numbers the only ones divisble by 4 are those where the last 2 digits are 00, 56, or 60 (per the hint on divisibility by 4). That means you only have the first two digits to play with now. So you have 5*4 = 20 possibilities for each ending 2-digit sequence. Because there are 3 of these (i.e., 00, 56, and 60) you have 3*20=60 different possibilities of a 4-digit number that is divisible by 4.

Without repetition there are Permut(5,4) = (5*4*3*2*1)/(4*3*2*1) = 5 different 4-digit numbers for each of the 5 different possibilities of the first digit. Thus there are 5*5 = 25 different 4-digit numbers you can make out of the integers in question (without any of the digits being used more than once). If you reverse this idea so that the first and second digit are the 00, 56, or 60 (reversed to be 00, 65, and 06) then you have 3 remaining integers to choose the remaining 2 digits from. Thus you have (3*2*1)/(2*1)=3 possibilities for each of the 3 bases. Therefore, without repetition, you have 3*3=9 different 4-digit numbers that can be made from (0,1,3,5,6) without repeating any of the digits.

...
T

In short, there are only 100 digits with repetition. thanks to all who post and clarify their answer!

...
T

I don't get the exact computation on how to do that.

...