5. Let $n (n<150)$ be a positive integer, and $n^{3}+23$ is divisible by 24. How many such $n$ are there?
(A)6
(B) 7
(C) 11
(D) 12
5.B.

From the given, we have $24 \mid\left(n^{3}-1\right)$. Therefore,
$$
\begin{array}{l}
n^{3}-1=(n-1)\left(n^{2}+n+1\right) \\
=(n-1)[n(n+1)+1] .
\end{array}
$$

Since $n(n+1)+1$ is odd, it must be that $2^{3} \mid (n-1)$.
If $3 \mid (n-1)$, then $3 \mid n(n+1)$.
Thus, $3 \mid [n(n+1)+1]$.
Therefore, it must be that $3 \mid (n-1)$.
This means $24 \mid (n-1)$, i.e., $n=24k+1(k \in \mathbf{Z})$.
From $24k+1<150$, we know that $k$ can take the values $0,1,2,3,4, 5,6$, so there are 7 such $n$: $1,25,49,73,97,121,145$.