samedi 7 mars 2015

Finding all the possible combination of sum of a number



I want to write a methon in Java that will take input as a number and will give output as an ArrayList of all Array of integers that can form the sum of the given number. For my application number that is taken as input is greater than 4 and less than 30 and 1 is not to be included in the numbers from which summ is computed.


For example for the input of 9 method should return ArrayList as follows


input -- 9


output will be ArrayList of following array of integer. [2,7][3,6][4,5][5,4][6,3][7,2][2,2,5][2,3,4][2,4,3][2,5,2][3,2,4][3,3,3][3,4,2][4,2,3][4,3,2][5,2,2][2,2,2,3][2,2,3,2][2,3,2,2][3,2,2,2]




Aucun commentaire:

Enregistrer un commentaire