You have an inexhaustible supply of $5$-cent and $8$-cent stamps.
List all possible ways of obtaining a total value of $40$ cents with these stamps.
I used a probability tree to solve this problem. But I feel like there's a better way and the probability tree took too much time. There are more questions like this and they the cents turn into dollars and they keep getting bigger.
I was wondering if anyone has a more efficient way?

First, see that $40$ can be divided by $5$ and $8$, and so you get $5 \times 8.$ That means you can get $40$ by using $8$ $5$-cent stamps or using $5$ $8$-cent stamps.
Now using both stamps :
Check if there are any positive integer solutions for $a$ and $b$:
$5a + 8b=40$
$8b=40-5a$
$40 - 5a$ is a multiple of $5$ which is smaller than $40$ so $8b$ has to be a multiple of $5$ which is smaller than $40$
but no such $b$ exists so the answers are $8$ $5$-cent stamps or $5$ $8$-cent stamps