A pattern can be seen in the solution that the result will be equal to (n/2)*m . May be I am missing any mathematical concept behind this reason. Can anyone provide me the mathematical logic behind the solution? Why is this working?
n being divisible by 2m gives us the info that there will be equal number of positive and negative groups. Now lets take numbers from successive positive and negative group. Eg. - n=12 and m=3 -1 -2 -3 +4 +5 +6 -7 -8 -9 +10 +11 +12
In successive +ve and -ve groups, the sum of corresponding elements is m. Eg. - In 1st +ve and 1st -ve group we have -
4 + (-1) =3
5 + (-2) = 3
6 + (-3) = 3
Choosing elements from successive +ve and -ve groups we get m for each pair of numbers in the sequence. Thus answer = m*(no. of pairs) = m*(n/2)