This problem is called integer Partitioning. There is a recursive formula to list all possible partitions of an integer. Given a number of 4 you could generate the following sets of values:
2 1 1
1 1 1 1
Please refer to Wiki-Partitions for details. Unfortunately, it is not a trivial calculation.
There is another problem related to this that is called Money Changing Problem or Change Making Problem , where you'd be interested in specific values rather than getting all possible values. For example changing Five Dollars in a country where there is no 4 dollar notes or coins.
For such problems you may use R, Mathmatica, etc.