## Fives and Eights

Find the greatest positive integer that cannot be expressed as a multiple of $5$, as a multiple of $8$, or as a sum of a multiple of $5$ and a multiple of $8$.
Source: mathcontest.olemiss.edu 3/24/2014

SOLUTION
What kind of numbers satisfy the requirements? We look at numbers that are not multiple of $5$ or not multiple of $8$ and try to express them as a sum of a multiple of $5$ and a multiple of $8$. If we cannot, the numbers satisfy the requirements.
$6=5+1\qquad\mathbf{Yes}$
$7=5+2\qquad\mathbf{Y}$
$9=5+4\qquad\mathbf{Y}$
$=8+1$
$11=5+6\qquad\mathbf{Y}$
$=10+1$
$=8+3$
$12=5+7\qquad\mathbf{Y}$
$=10+2$
$=8+4$
$13=5+8\qquad\mathbf{No}$
$14=5+9\qquad\mathbf{Y}$
$=10+4$
$=8+6$
$17=5+12\qquad\mathbf{Y}$
$=10+7$
$=15+2$
$=8+9$
$=16+1$
$18=5+13\qquad\mathbf{N}$
$=10+8$
$19=5+14\qquad\mathbf{Y}$
$=10+9$
$=15+4$
$=8+11$
$=16+3$
$21=5+16\qquad\mathbf{N}$
$22=5+17\qquad\mathbf{Y}$
$=10+12$
$=15+7$
$=20+2$
$=8+14$
$=16+6$
$23=5+18\qquad\mathbf{N}$
$=10+13$
$=15+8$
$26=5+21\qquad\mathbf{N}$
$=10+16$
$27=5+22\qquad\mathbf{Y}$
$=10+17$
$=15+12$
$=20+7$
$=25+2$
$=8+19$
$=16+11$
$=24+3$
From $28$ on all numbers not ending in $0$ or $5$ can be expressed as a sum of a multiple of $5$ and a multiple of $8$ by the following rules.
If the number ends in $1$, subtract $16$ and get a sum = $xxx5+16$
If the number ends in $2$, subtract $32$ and get a sum = $xxx0+32$
If the number ends in $3$, subtract $8$ and get a sum = $xxx5+8$
If the number ends in $4$, subtract $24$ and get a sum = $xxx0+24$
If the number ends in $6$, subtract $16$ and get a sum = $xxx0+16$
If the number ends in $7$, subtract $32$ and get a sum = $xxx5+32$
If the number ends in $8$, subtract $8$ and get a sum = $xxx0+8$
If the number ends in $9$, subtract $24$ and get a sum = $xxx5+24$
$27$ is the greatest positive integer that cannot be expressed as a multiple of $5$, as a multiple of $8$, or as a sum of a multiple of $5$ and a multiple of $8$.

Answer: $27$