I have a set of integers M and a target sum k. I want to find the subset of M that when added together is the closest to k without going over.
For example:
If the target sum k is not too large, look at http://en.wikipedia.org/wiki/Subset_sum_problem#Pseudo-polynomial_time_dynamic_programming_solution - you can use this to create a bitmap which tells you which numbers can be produced using your subset. Then just pick the closest possible number to k in the bitmap.