0

Help me write an algorithm to decompose n on k summands

Write all combinations of k summands a1+a2+...+ak=n

29th Sep 2018, 6:26 AM
can_be_better
can_be_better - avatar
6 Answers
+ 1
What do you mean? is this what you want? https://code.sololearn.com/cEUAF1jGB52u/?ref=app
30th Sep 2018, 11:10 AM
ShortCode
+ 1
ShortCode I don't know ruby. what input?
2nd Oct 2018, 10:15 AM
can_be_better
can_be_better - avatar
+ 1
Ohh... i think i failed to understand your question. can_be_better i write the program to find the combination of the string input... sorry...
2nd Oct 2018, 12:01 PM
ShortCode
+ 1
can_be_better Where is your try? Futhermore, there is some constrain about summands? If they can be negative integer also, there are infinite combinations
2nd Oct 2018, 12:11 PM
KrOW
KrOW - avatar
+ 1
true KrOW
2nd Oct 2018, 12:13 PM
ShortCode
0
KrOW ShortCode https://code.sololearn.com/cyLi65G5aYxv/?ref=app there it is. but it outputs not all combinations yes, all values are natural and n is bigger than k
3rd Oct 2018, 12:50 PM
can_be_better
can_be_better - avatar