# splitting integer problem

I want to cut the integer into small numbers and show me all the possibilities. For example, if I choose integer 6, then I would like to know how many combination of a 5 dimensional vector (or table ?) can show the cutting. That is the column label of the 5 dimensional number are from 1 to 5, as 6 can be cut into 6 1, then the result would be (6,0,0,0,0). it can also be cut into one 4 and one 2, then the result would be (0,1,0,1,0). or three 2 ->(0,3,0,0,0).

How to code this? Thanks a lot!

## 2 Answers

split = FrobeniusSolve[Range[# - 1], #] &;
split[6]

{{0, 0, 2, 0, 0}, {0, 1, 0, 1, 0}, {0, 3, 0, 0, 0}, {1, 0, 0, 0, 1}, {1, 1, 1, 0, 0},
{2, 0, 0, 1, 0}, {2, 2, 0, 0, 0}, {3, 0, 1, 0, 0}, {4, 1, 0, 0, 0}, {6, 0, 0, 0, 0}}


Alternatively:

split[n_]:=Normal@SparseArray[Normal@Counts[#], n] & /@ IntegerPartitions[n]

split[6]

{{0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 1, 0}, {0, 1, 0, 1, 0, 0},
{2, 0, 0, 1, 0, 0}, {0, 0, 2, 0, 0, 0}, {1, 1, 1, 0, 0, 0},
{3, 0, 1, 0, 0, 0}, {0, 3, 0, 0, 0, 0}, {2, 2, 0, 0, 0, 0},
{4, 1, 0, 0, 0, 0}, {6, 0, 0, 0, 0, 0}
}