The solution might be:
- Write the number as a serie of 1. (5 = 1+1+1+1+1) and put it in a proper variable (something like an array). We can call it seq.
- Sum the first two elements of the list ad put the result in another list if it doesn't already exist (neither itself or one of its permutations)
- If the procedure has only two numbers left, come back to the variable seq and sum the last two elements, go to 2, otherwise, if you have more than two elements left, go to 2 without doing anything.
To write the algorithm which checks for dobules in the final list, I suggest:
- The final list must be a list of arrays
- When you check for doubles, sort the elements of the current element of the list, without changing it (do it in a temporary array) and sort the one you've found too. If they contains the same elements in the same positions, it is already in the array, so do not add the result you've found to the list, otherwise, add it!!
To summarize up a bit you need:
- A number which is the starting point (x).
- An array which contains the current result (initial value: x elements set to 1)
- An array which contains the initial point (it is modified at the point 3 of the procedure if only 2 items are left by the procedure. We can call this array Source)
- A list which contains the results
You only have to sum the first element of the array to the second until you have only 2 elements and when this happens, come back to the array Source and sum the last two elements. Call the procedure you have done(sum the first two elements). Do it until you have two elements left in the Source array.
I hope it's helped to solve the problem.
Sorry for my bad English.
Jymmy097