How to divide total price into sum of multiple of numbers

92 Views Asked by At

How to divide total price into sum of multiple of numbers so that the sum is close to price as much as possible. Is there any formula?

Example: Price: 1256.7

Numbers: 5.7, 3.6, 4.9, 10.1, 12.3, 6.8

Sulution should look like: 1256.7 = 5x5.7 + 30x3.6 + 0x4.9 ....

I search for a formula to find how to get close to price using sum of multiple Numbers