find combination of numbers that equal a given sum X++

Hi team,

This is logical/analytical question .

There are is value for ex. 100 . And i have to loop a table value to with possible combination to get 100 . Any idea on the Algorithm here or anywhere AX has code .

Target = 100

Tabevalues are 10,9,70,50,30,20 . I need to add 10+ 70+20 = 100 . Any first possible combination to achive 100

Anything will be appricted

It’s called the subset sum problem and you may want to know that it’s NP-complete. The link shows some approaches and when you know the name, you can search for more resources.

A nice solution may be using Microsoft Solver Foundation, which is already utilized in newer versions of AX.