On Mar 11, 9:33 am, saurabh agrawal <[email protected]> wrote:
> Given an integer n , you have to print all the ways in which n can be
> represented as sum of positive integers
I suggest you
1) generate the numeric partitions of n.
That's the lists of numbers in sorted order whose sum is n.
e.g. The numeric partitions of 3 are: {(1,1,1), (1,2), 3}
2) For each partition generate its multiset permutations.
Note: there is a formula for how many of sums of positive integers to
n
there are but I don't what it is.
Regards,
Ralph Boland
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.