Answer: (a) \(510\); (b) \(540\).
Answer: (a) \(510\); (b) \(540\).
(a) The number must be greater than \(5000\), so the first digit can be \(5,6,7,8\) or \(9\). It must also be odd, so the last digit must be \(3,5,7\) or \(9\).
If the first digit is \(5,7\) or \(9\), then the last digit can be one of the other three odd digits. The two middle digits can then be chosen in \(6\times5\) ways. This gives
\(3\times3\times6\times5=270.\)
If the first digit is \(6\) or \(8\), then the last digit can be any of the four odd digits. This gives
\(2\times4\times6\times5=240.\)
Therefore the number of possible codes is
\(270+240=510.\)
(b) The last digit must be prime, so it is \(2,3,5\) or \(7\). The number must be greater than \(5000\).
If the first digit is \(5\) or \(7\), then the last digit can be one of the other three prime digits. This gives
\(2\times3\times6\times5=180.\)
If the first digit is \(6,8\) or \(9\), then the last digit can be any of the four prime digits. This gives
\(3\times4\times6\times5=360.\)
Therefore the number of possible codes is
\(180+360=540.\)