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
. We can expand this as
![100a + 10b + c](https://img.qammunity.org/2023/formulas/mathematics/college/7md73o144d2cwa3jeb27p0e2axdrma4dla.png)
In order for this to be divisible by 4, we observe that
![100a + 8b + 2b + c = 4 (25a + 2b) + (2b+c)](https://img.qammunity.org/2023/formulas/mathematics/college/62n53n8zwtvvlckwvgj1b1t91ytrgdsl5t.png)
so we only need
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
, we need
![c=0 \implies 2b=4k \implies b=2k](https://img.qammunity.org/2023/formulas/mathematics/college/83bqvalk4p7qev8hluhxj0h2bb4maua9hd.png)
![c=2 \implies 2b+2=4k \implies b = 2k-1](https://img.qammunity.org/2023/formulas/mathematics/college/xboq86glp53zlkxuj5vtnbtaa18y4u9kwg.png)
![c=4 \implies 2b+4 = 4k \implies b = 2(k-1)](https://img.qammunity.org/2023/formulas/mathematics/college/ex1p1s9vblxc7y6udmhl72u0iz3o2hklxn.png)
![c=6 \implies 2b+6 = 4k \implies b = 2k-3](https://img.qammunity.org/2023/formulas/mathematics/college/zs6isaj017zma9ftw1m414xmle4my1m1kg.png)
![c=8 \implies 2b+8=4k \implies b = 2(k-2)](https://img.qammunity.org/2023/formulas/mathematics/college/f1d46bhjoqg0uy78lv8o1f1tbwlv0ddkmi.png)
Ignoring
for the moment, in the cases of
,
is also even. This leaves 3 choices for
and 2 choices for
.
Likewise, in the cases of
,
is odd. This leaves 2 choices for
and 5 choices for
.
Now taking into account the choice for
, we have the following decision tree.
• If
and
, then
- a total of 2•3•3 = 18 codes.
• If
and
, then
- a total of 2•2•3 = 12 codes.
• If
and
, then
- a total of 2•1•5 = 10 codes.
• If
and
, then
- a total of 2•2•5 = 20 codes.
• If
and
, then
- a total of 5•3•4 = 60 codes.
• If
and
, then
- a total of 5•2•4 = 40 codes.
Hence there are a total of 18 + 12 + 10 + 20 + 60 + 40 = 160 codes.