Combination Sum Calculator

Find all number combinations that add up to a target value.

This calculator uses a backtracking algorithm. Repeated use of the same number is allowed, which matches the standard combination sum problem.

About the Author: Created by Fotios Angelakis, MSc in Mechanical Engineering, with experience in engineering calculations, data analytics, and numerical tools. Learn more about the author's qualifications and experience.

Enter a list of positive numbers and a target sum.

How the Combination Sum Calculator Works

This Combination Sum Calculator finds all possible combinations of numbers that add up to a selected target value. It is useful for mathematics, programming challenges, budgeting problems, optimization tasks, and algorithm learning.

The calculator can also be used as a target sum calculator, number combination finder, or educational helper for understanding recursive search problems.

[] [2] [3] [7] [2,2,3] ✓ exceeds ✕ [7] ✓ Backtracking explores possible paths

Combination Sum Problem

The combination sum problem asks:

Which combinations of the given numbers add up exactly to the target value?

For example, if the numbers are [2, 3, 6, 7] and the target is 7, the valid combinations are:

[2, 2, 3]
[7]

Algorithm Used

The calculator uses a backtracking algorithm. Backtracking is a recursive search method that builds possible solutions step by step.

The process works like this:

  1. Start with an empty combination.
  2. Add one number from the input list.
  3. Subtract that number from the remaining target.
  4. If the remaining target becomes zero, record the combination.
  5. If the remaining target becomes negative, stop that branch.
  6. Backtrack and test the next possible number.
remaining target = target - selected number

How to Use the Calculator

  1. Enter positive numbers separated by commas.
  2. Enter the target sum.
  3. Click Find Combinations.
  4. Review the valid combinations and total number of results.

Example 1: Target Sum of 7

Suppose the input is:

Numbers = [2, 3, 6, 7]
Target = 7

The calculator finds:

[2, 2, 3]
[7]

Total Combinations: 2

Example 2: Target Sum of 8

For:

Numbers = [1, 3, 5]
Target = 8

The valid combinations are:

[1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 3]
[1, 1, 1, 5]
[1, 1, 3, 3]
[3, 5]

Total Combinations: 5

Combination Sum vs Subset Sum

Calculator Type Meaning Can numbers repeat?
Combination Sum Find combinations that reach a target value. Yes
Subset Sum Find a subset of numbers that reaches a target value. Usually no
Important: This page calculates the combination sum version, where the same number can be used more than once.

Real-World Uses

  • Budget planning: Find combinations of costs that reach a budget.
  • Programming practice: Learn recursion and backtracking.
  • Optimization problems: Explore possible combinations under a target.
  • Mathematics education: Understand combinatorics and recursive algorithms.
  • Financial modeling: Test combinations of payments, investments, or values.

Frequently Asked Questions

What does this calculator find?

It finds every valid combination of the entered numbers that adds up exactly to the target sum.

Can the same number be used more than once?

Yes. This calculator allows repeated use of numbers. For example, if 2 is entered, combinations such as [2, 2, 3] are allowed.

Does the calculator remove duplicate input values?

Yes. If you enter 2, 2, 3, 6, 7, the duplicate 2 is removed before calculation to avoid repeated identical results.

Why are the results sorted?

The calculator sorts the input numbers so that combinations are displayed in a clean and consistent order.

Can I use decimals?

This version is designed for positive whole numbers. For reliable results, enter integers such as 1, 2, 3, 5.