try to do something like this for yourself:
40 different numbers on the list, 8 numbers of components (eg 234 + 1534 + 3456 +...+...+...+...+...) course, the program is to calculate all possible combinations of numbers for 8 of the 40 (Just add these numbers) in addition to a separate list notes the results of all combinations is exactly the sum of: 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000th
but I propose to use Newton's formula to even know how many of these loops to be. (The formula for the number of combinations)
It's just part of the task should execute the program at a loop.
Programs written in C + + do it without a problem