Let the required number be \( N \).
We are given that:
\[
N \equiv 1 \, (\text{mod} \, 4), \quad N \equiv 2 \, (\text{mod} \, 5), \quad N \equiv 3 \, (\text{mod} \, 6), \quad N \equiv 4 \, (\text{mod} \, 7), \quad N \equiv 5 \, (\text{mod} \, 8)
\]
This implies:
\[
N + 3 \equiv 0 \, (\text{mod} \, 4, 5, 6, 7, 8)
\]
We need to find the least common multiple (LCM) of 4, 5, 6, 7, and 8:
\[
\text{LCM}(4, 5, 6, 7, 8) = 840
\]
Thus, \( N + 3 = 840k \) for some integer \( k \), and \( N = 840k - 3 \).
Now, we find the largest \( N \) that is a 5-digit number:
\[
840k - 3 \leq 99999
\]
\[
840k \leq 100002
\]
\[
k \leq \frac{100002}{840} = 119
\]
For \( k = 119 \):
\[
N = 840 \times 119 - 3 = 99957
\]
Thus, the greatest number is 99957.