I was stumbled upon a math problem that I can't seem to solve efficiently.
I was asked to create a group of a consecutive number that sums up to a whole number, e.g.
4,3,2,1 = 10
4,3,2 = 9
5,4,3,2 = 14
constraints:
- the group of numbers doesn't need to reach to 0 or 1
- the group of numbers needs to be consecutive
- the group of numbers has to be smallest size (if there are more than one groups)
Is there a math logic that can help me to get the number grouping efficiently, without having to create all the possible combinations first?