Implement an integer partition with O(sum ^ n) and it could be sped up using DP to O(sum * n).