mardi 8 octobre 2019

a* 15 + b* 32 + c* 4 + d*52 = 299 Write program in Python/Java/Excel to solve for a,b,c,d

I hope i can make clear what i want to do. I have certain Numbers. For example 15,32,4,52 ...(around 30 different numbers) And have the number 299. (Could be another) how often do i need to multiply the numbers 15,32,4,52 to get to 299.

a* 15 + b* 32 + c* 4 + d*52 = 299

This would be a solution. 5*15 + 1*32 + 9*4 + 3*52 = 299

and also this: 5*15 + 2*32+1*4 +3*52 = 299

It doesn't matter which is var is multiplied more often. It just needs to add in total to the endSum(in my Example 299) I thought of a Linear equation system. But couldn't think of a solution which is efficient. Google didn't help me, because i don't know how to formulate my question properly. It would be great if the solution could be adapted to Python/Java/Excel.

Thanks in Advance!




Aucun commentaire:

Enregistrer un commentaire