Let's call them

`x`

, `y`

, and `z`

, and call the target the user entered `t`

So you are looking for a solutions where

a * x + b * y * c * z = t

There are two possible outcomes here:

1) There is no combination of the three numbers that equals t. This will be the most common!

2) There are combinations.

So start with the largest one of

`x`

, `y`

, and `z`

.Subtract it from

`t`

. If the result is positive, set t to it, and count it. Go back around and do it again.If not, there are no more large values that can be fitted in there, so repeat the exercise with the next biggest., and so on until you run out of

`x`

, `y`

, and `z`

.If at any point

`t = 0`

, you're done and found a match.To find the next matches, start with the second largest, and repeat the process.

Try it on paper, and you'll see what I mean.

I'd suggest that this is probably well suited to a recursive solution, but the code is up to you - this is your homework, after all!