I want to ask you to tell me the correct algorithm.
There is a number x = 112;
And the array (20,30,38).
Both the number and the array can change.
I need to get a number as close as possible to the number X from the sum of the array elements, provided that the numbers from the array can be repeated.
That is, from the example I need
20+20+20+20+30 = 110 ( remainder 2)
or
30+30+30+20 = 110 ( remainder 2)
Thank you in advance for your advice.