Mechaniker: One line solutions do not necessarily always give the complete answer.
In this case, for eg;,
(1) your 1-liner assumes even values for m, but doesn’t say it.
(2) n has non-unique values. Your method gives just the max value for n, that sums 2 numbers (max and min of those left) at a time.
Solutions for even m in general: n is the result minus 1 of division by x>m of sum(1 thru m) such that the sum is integrally divisible by x.
So when m=12: n= (78/x - 1); x being 13, 26 and 39 (78 being the trivial case)