59.6k views
11 votes
How many distinct 3 digit code can i create such that this code is divisible by 4.

For example these codes are rejected since they have repeating numbers/less than 3 digits:
024/100/112/996/444


User Lisi
by
5.4k points

1 Answer

8 votes

The other answer is just wrong.

There are 9•9•8 = 648 distinct 3-digit codes. The first digit can be any numeral from 1-9, the next digit can be any from 0-9 minus the one used in the first position, and the last digit can be any from 0-9 minus both the numerals used in the first two positions.

But that doesn't even account for the divisibility constraint.

Let the code be
abc. We can expand this as


100a + 10b + c

In order for this to be divisible by 4, we observe that


100a + 8b + 2b + c = 4 (25a + 2b) + (2b+c)

so we only need
2b+c to be divisible by 4.

The last digit must be even, so there are only 5 choices for the last digit. I list the possibilities and outcomes below. For some integer
k, we need


c=0 \implies 2b=4k \implies b=2k


c=2 \implies 2b+2=4k \implies b = 2k-1


c=4 \implies 2b+4 = 4k \implies b = 2(k-1)


c=6 \implies 2b+6 = 4k \implies b = 2k-3


c=8 \implies 2b+8=4k \implies b = 2(k-2)

Ignoring
a for the moment, in the cases of
c\in\{0,4,8\},
b is also even. This leaves 3 choices for
c and 2 choices for
b.

Likewise, in the cases of
c\in\{2,6\},
b is odd. This leaves 2 choices for
c and 5 choices for
b.

Now taking into account the choice for
a, we have the following decision tree.

• If
a\in\{2,6\} and
c\in\{0,4,8\}, then
b\in\{0,2,4,6,8\}\setminus\{a,c\} - a total of 2•3•3 = 18 codes.

• If
a\in\{4,8\} and
c\in\{0,4,8\}\setminus\{a\}, then
b\in\{0,2,4,6,8\}\setminus\{a,c\} - a total of 2•2•3 = 12 codes.

• If
a\in\{2,6\} and
c\in\{2,6\}\setminus\{a\}, then
b\in\{1,3,5,7,9\}\setminus\{a,c\} - a total of 2•1•5 = 10 codes.

• If
a\in\{4,8\} and
c \in\{2,6\}, then
b\in\{1,3,5,7,9\} - a total of 2•2•5 = 20 codes.

• If
a\in\{1,3,5,7,9\} and
c\in\{0,4,8\}, then
b\in\{0,2,4,6,8\}\setminus\{c\} - a total of 5•3•4 = 60 codes.

• If
a\in\{1,3,5,7,9\} and
c\in\{2,6\}, then
b\in\{1,3,5,7,9\}\setminus\{a\} - a total of 5•2•4 = 40 codes.

Hence there are a total of 18 + 12 + 10 + 20 + 60 + 40 = 160 codes.

User Xiaodong Liang
by
5.7k points