# can a computer take a figure like 43 and break it down to all combinations of numbers that make up that sum? ie. 43=10+10+10+5+5+3? I may have put this in the wrong place. I was hoping for...

can a computer take a figure like 43 and break it down to all combinations of numbers that make up that sum?

ie. 43=10+10+10+5+5+3?

I may have put this in the wrong place. I was hoping for a way for a computer (hopefully excel can do it) to be able to break down, ALL possible combinations of figures that add up to a 2 digit sum number (1- 99) .. (The two digit number being the answer of the sum of numbers that make it up). Yes, working backwards from the answer. To illustrate further the examples below together with the above examples :

43=5+5+5+5+5+5+2+3+1+4+3

43=2+3+2+3+2+3+2+3+2+3+2+3+1+4+1+4+3

43=20+20+3

43=15+10+12+1+5 <examples only>

23=5+5+7+6

23=5+6+6+6

56=10+10+5+5+7+3+2+8+6

56=5+5+5+5+2+3+2+3+7+3+2+8+6

12=6+6

12=3+3+3+3

12=1+2+1+2+1+2+1+2

12=9+3

12=7+5

12=8+4

12=4+4+2+2

I know that the list can be extensive, that's why I've only used samples to show what I'm trying to achieve and why I need a computer to do the work for me. I apologise for my lack of having the right terminology to explain myself. Thank you for your effort.

### 2 Answers | Add Yours

I'm not clear on the goal of your question. Is your task a computer programming task for which you are to produce a computer-based solution to the problem for any two digit number? Is it the number theory task of proposing an algorithm that will produce the solution for any two digit number? Or do you just want a tool that will give you all the possibilities for a given two-digit number?

I'm going to try to answer the third because that's the easiest, but I can't immediately think of a way to do it on Excel. Here is a Mathematica solution for 8 (easily adapted to any other number, two-digit or otherwise). It's anything but elegant, but I think it's easier to understand what I've done written this way.

So that I don't have to worry about redundant answers like 13 = 5 + 5 + 3 and 13 = 5 + 3 + 5, I'm just counting how many times the number 5 shows up, and how many times the number 3 shows up, whatever the order, in my first function. I do that by asking Mathematica to record the count of how many times each possible addend appears from 0 to the maximum number of times that addend can fit in whatever is left after accounting for the higher-valued addends. Flatten and Partition are used just to keep from having lists within lists in my output.

**
**

countsfor8=Partition[Flatten[

Table[{n8,n7,n6,n5,n4,n3,n2,n1},

{n8,0,(8)/8},

{n7,0,(8-8*n8)/7},

{n6,0,(8-8*n8-7*n7)/6},

{n5,0,(8-8*n8-7*n7-6*n6)/5},

{n4,0,(8-8*n8-7*n7-6*n6-5*n5)/4},

{n3,0,(8-8*n8-7*n7-6*n6-5*n5-4*n4)/3},

{n2,0,(8-8*n8-7*n7-6*n6-5*n5-4*n4-3*n3)/2},

{n1,(8-8*n8-7*n7-6*n6-5*n5-4*n4-3*n3-2*n2),(8-8*n8-7*n7-6*n6-5*n5-4*n4-3*n3-2*n2)}]

],8]

Then I wrote a second function to convert the lists of how many times a number appeared in the sum into an actual equation.

**writeout8[{n8_,n7_,n6_,n5_,n4_,n3_,n2_,n1_}]:=**

StringDrop[StringJoin[Flatten[{"8=",

Table["8+",{i,n8}],

Table["7+",{i,n7}],

Table["6+",{i,n6}],

Table["5+",{i,n5}],

Table["4+",{i,n4}],

Table["3+",{i,n3}],

Table["3+",{i,n2}],

Table["1+",{i,n1}]

}]],-1]

Below are the results for the sum of 8. I hope it's clear how to adjust the code for other numbers and that you have access to mathematica on your campus.

**
**

**TableForm[Table[writeout8[countsfor8[[i]]],{i,Length[countsfor8]}]]**

{

{8=1+1+1+1+1+1+1+1},

{8=2+1+1+1+1+1+1},

{8=2+2+1+1+1+1},

{8=2+2+2+1+1},

{8=2+2+2+2},

{8=3+1+1+1+1+1},

{8=3+2+1+1+1},

{8=3+2+2+1},

{8=3+3+1+1},

{8=3+3+2},

{8=4+1+1+1+1},

{8=4+2+1+1},

{8=4+2+2},

{8=4+3+1},

{8=4+4},

{8=5+1+1+1},

{8=5+2+1},

{8=5+3},

{8=6+1+1},

{8=6+2},

{8=7+1},

{8=8}

}

yes if you put in the correct way