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

Respuesta :

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 [tex]abc[/tex]. We can expand this as

[tex]100a + 10b + c[/tex]

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

[tex]100a + 8b + 2b + c = 4 (25a + 2b) + (2b+c)[/tex]

so we only need [tex]2b+c[/tex] 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 [tex]k[/tex], we need

[tex]c=0 \implies 2b=4k \implies b=2k[/tex]

[tex]c=2 \implies 2b+2=4k \implies b = 2k-1[/tex]

[tex]c=4 \implies 2b+4 = 4k \implies b = 2(k-1)[/tex]

[tex]c=6 \implies 2b+6 = 4k \implies b = 2k-3[/tex]

[tex]c=8 \implies 2b+8=4k \implies b = 2(k-2)[/tex]

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

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

Now taking into account the choice for [tex]a[/tex], we have the following decision tree.

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

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

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

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

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

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

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