I am struck in a tricky situation where I need to calculate the number of combinations to form 100 based on different factors.
Those are
Why can't you use a brute force approach with few optimization? For example, say N - Number of combinations M - Multiples D - Max possible Distance
So possible values in combinations can be M, 2M, 3M and so on. You need to generate this set and then start with first element from set and try to find out next two from choosing values from same set (provided that they should be less than D from first/second value). So with i/p of 3-10-30 would
If you use a recursion then solution would become even simpler.
Worst performance will happen when M = 1 and N is sufficiently large.