If you need to find all unique number combinations that add up to a target, this free combination sum calculator can help instantly. It is useful for coding interview prep, backtracking practice, puzzle solving, and any target-sum analysis where order should not matter.
Interactive Combination Sum Calculator
Enter a set of positive integers and a target. The calculator will return unique combinations whose sum equals the target.
2,3,5 or 1 2 4 8What is a combination sum?
A combination sum problem asks: “Given a list of numbers, which unique groups of those numbers add up to a target?” The key detail is that combinations are order-independent. So [2, 3, 2] and [3, 2, 2] are treated as the same combination.
How this calculator works
- Reuse allowed mode: each candidate can be used multiple times (classic backtracking version).
- Use each number once mode: each value instance is used at most once, with duplicate-combination filtering.
- Sorted search: candidates are sorted so impossible branches can stop early.
- Result cap: a max-results limit prevents browser slowdowns on very large searches.
Step-by-step examples
Example 1: Reuse allowed
Input: candidates 2, 3, 6, 7, target 7
Output combinations:
[7][2, 2, 3]
Example 2: Use each number once
Input: candidates 10, 1, 2, 7, 6, 1, 5, target 8
Unique combinations include:
[1, 1, 6][1, 2, 5][1, 7][2, 6]
Combination sum vs nCr (combinations formula)
This tool is different from a standard combinations formula calculator (nCr). The formula nCr answers how many ways to choose r items from n, while this tool searches for subsets that hit a numeric target sum.
Where this is useful
- Coding interview preparation (backtracking and recursion).
- Constraint-based puzzle solving.
- Budget and package planning with exact totals.
- Educational demos for subset sum and search trees.
Tips for better performance
- Use a smaller candidate set when possible.
- Increase numbers relative to target to reduce branch depth.
- Set a practical max-results cap for large inputs.
- Prefer “use each number once” when reuse is not required.
Frequently asked questions
Does order matter?
No. This calculator returns unique combinations only, not permutations.
Can I enter duplicate numbers?
Yes. In single-use mode, duplicates are handled carefully so duplicate output combinations are removed. In reuse mode, duplicates are internally deduplicated.
Why did I get no results?
That simply means no valid subset of your candidates reaches the target under the selected mode.