Rewrite an Integer as a Sum

The Rewrite an Integer as a Sum tool takes a positive integer and finds all the different ways you can break it down into additive parts. For example, the number 5 becomes 4+1, 3+2, 2+2+1, and more depending on the rules you apply.

You can set the maximum number of terms, choose whether parts must be unique, and toggle whether you want to include permutations (e.g., count 3+2 and 2+3 separately). It updates instantly, and you can output the results as a list, CSV, or JSON array perfect for data work, puzzles, or just exploring number patterns.

Paste your input above or import a file below.
No file chosen
Supported file types: .txt, .csv, .tsv, .log, .json, .xml, .md, .ini, .yaml, .yml, .html, .htm, .css
Total items: 0
Options
Use unique numbers only
Include permutations
Maximize output
Output format:

How to Use:

  • Enter a number (like 7) in the Input Integer box
  • Or import a plain-text file with a single number
  • Use the Options box to refine the results:
    • Use unique numbers only – prevents repeated parts like 2+2+3
    • Include permutations – lets you include reordered versions like 3+2 and 2+3
    • Max terms – limits how long each sum can be
  • Pick your Output format:
    • One per line (default)
    • CSV
    • JSON array
  • Enable Maximize output to see more results at once
  • Results update automatically with a flashing output box
  • Use Copy Output or Export to File to save the output
  • Click Clear All to reset everything

What Rewrite an Integer as a Sum can do:

  • Generate all additive decompositions of any positive integer
  • Filter sums by uniqueness and number of terms
  • Control output format for scripting, analysis, or display
  • Count and display total number of unique results
  • Import and export data for advanced workflows
  • Show permutations or stick to distinct combinations only
  • All updates and calculations happen live in your browser

Example:

Input:

5

Output (Line format, permutations on):

4+1
3+2
2+3
2+2+1
2+1+2
1+2+2
1+1+3
1+3+1
3+1+1
...

Output (Unique only, permutations off):

4+1
3+2
2+2+1
1+1+1+2

Common Use Cases:

Whether you’re teaching math, solving number puzzles, writing combinatorics code, or just curious about how numbers break down this tool makes it easy to explore integer partitions and sums. Tweak a few options, copy the output, and you’re done. No setup, no code, just the answers.

Useful Tools & Suggestions:

After using Rewrite an Integer as a Sum, try Decompose an Integer to break it down further into its structural components. You can also run Add Integer Digits if you want a quick sum of just the digits instead of full parts.