>>107253376
in haskell this is just
import Data.Foldable
import Data.List
combinationSum candidates target = go target [] (sort candidates)
where
go 0 res _ = pure res
go _ res [] = mempty
go n res (x : xs)
| x > n = mempty
| otherwise = [0 .. n `div` x] >>= \amt ->
go (n - x * amt) (replicate amt x <> res) xs
-- test cases
main = traverse_ (print . uncurry combinationSum)
[ ([2,3,6,7],7)
, ([2,3,5], 8)
, ([2], 1)]