5. Here you have 4 choices to make: one's digit, ten's digit, hundred's digit and thousand's digit. However, since the final number must not be divisible by 5, the one's position cannot contain a 5. Think of having four positions and write down the number of possible ways in which to fill each position.
thousand's (anything) | hundred's (anything) | ten's (anything) | one's (4,6 or 7) |
3 | 2 | 1 | 3 |
Choose the final digit first, there are three choices for the one's digit. Then choose the thousand's digit, you can use any of the remaining three digits. Next choose the hundred's digit, you can use any of the remaining two digits. Finally there is only one choice of digit to put in the remaining position.
The total number of 4-digit numbers which are not divisible by 5 which can be created using the digits 4, 5, 6 and 7 is 3 · 2 · 1 · 3 = 18.