[Question]
  [
Before anyone says anything, [similar](https://codegolf.stackexchange.com/questions/2958/check-if-number-is-a-sum-of-consecutive-numbers-or-not) and [similar](https://codegolf.stackexchange.com/questions/5703/in-how-many-ways-can-a-number-be-expressed-as-a-sum-of-consecutive-numbers). But this is not a dupe.
---
Some positive integers can be written as the sum of at least two consecutive positive integers. For example, `9=2+3+4=4+5`. Write a function that takes a positive integer as its input and prints as its output the **longest** sequence of increasing consecutive positive integers that sum to it (any format is acceptable, though -5 bytes if the output is the increasing sequence separated by `+` as shown above. If there exists no such sequence, then the number itself should be printed.
This is code golf. Standard rules apply. Shortest code in bytes wins.
---
**Samples** (note that formatting varies)
```
Input:   9
Output:  2,3,4
Input:   8
Output:  8
Input:   25
Output:  [3,4,5,6,7]
```
  
[Answer]
## Python, 67 bytes
```
f=lambda n,R=[1]:n-sum(R)and f(n,[R+[R[-1]+1],R[1:]][sum(R)>n])or R
```
An oddly straightforward strategy: search for the interval R with the right sum.
* If the sum is too small, shift the right endpoint of the interval up
one by appending the next highest number.
* If the sum is too large, shift up the left endpoint by removing the smallest element
* If the sum is correct, output R.
Since the bottom end of the interval only increases, longer intervals are found before shorter ones.
[Answer]
# Pyth, ~~12~~ 10 bytes
```
j\+hfqsTQ}M^SQ2
```
The code is **15 bytes** long and qualifies for the **-5 bytes** bonus. Try it online in the [Pyth Compiler](https://pyth.herokuapp.com/?code=j%5C%2BhfqsTQ%7DM%5ESQ2&input=9).
*Thanks to @Jakube for golfing off 2 bytes!*
### How it works
```
j\+hfqsTQ}M^SQ2    (implicit) Store evaluated input in Q.
            S      Compute [1, ..., Q].
           ^  2    Get all pairs of elements of [1, ..., Q].
         }M        Reduce each pair by inclusive range. Maps [a, b] to [a, ..., b].
    f              Filter; for each pair T:
      sT             Add the integers in T.
     q  Q            Check if the sum equals Q.
                   Keep the pair if it does.
   h               Retrieve the first match.
                   Since the ranges [a, ..., b] are sorted by the value of a,
                   the first will be the longest, in ascending order.
j\+                Join, using '+' as separator.
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~40~~ 32 bytes
```
{^/!'1+i@'*>-/i:&x=s-\:s:+\!1+x}
```
[Try it online!](https://ngn.codeberg.page/k#eJxLs6qO01dUN9TOdFDXstPVz7RSq7At1o2xKrbSjlE01K6o5eJKU7dUsFAwMlUw5AIAI+oLTw==)
*-8 bytes thanks to @ngn*
[Answer]
# Haskell, ~~49~~ 48 bytes
```
f n=[[a..b]|a<-[1..n],b<-[a..n],sum[a..b]==n]!!0
```
[Answer]
# [Jelly (fork)](https://github.com/cairdcoinheringaahing/jellylanguage), 5 bytes
```
ẆSƘ¹Ṫ
```
[Try it online!](https://tio.run/##y0rNyan8///hrrbgYzMO7Xy4c9X///@NTAE "Jelly – Try It Online") (or rather, don't)
For an extra [3 bytes](https://tio.run/##ARwA4/9qZWxsef//4bqGU8aYwrnhuapq4oCdK////zI1) (again, doesn't work on TIO), we can get a score of 3
## How it works
```
ẆSƘ¹Ṫ - Main link. Takes N on the left
Ẇ     - Cast N to range and get all contiguous, non-empty sublists
  Ƙ¹  - Keep those for which the following is equal to N:
 S    -   Sum
    Ṫ - Take the last (and longest) one
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 11 - 5 = 6 bytes
```
ɾÞS≬∑?=c\+j
```
Just like most of the other answers in golfing languages.
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLJvsOeU+KJrOKIkT89Y1xcK2oiLCIiLCIyNSJd)
Explanation:
```
ɾ            # Range from 1 to n
 ÞS          # All sublists
   ≬         # Three element lambda
    ∑        #   Sum
      =      #   Equals
     ?       #   The input
       c     # First truthy item under function application 
          j  # Join by:
        \+   # "+"
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 8 bytes
```
⟦₁s.+?!∧
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//9H8ZY@aGov1tO0fdSz//9/yfwQA "Brachylog – Try It Online")
### Explanation
```
⟦₁s.+?!∧
⟦₁         Inclusive range from 1 to the input number
  s        A consecutive sublist (trying longest sublists first)
   .       is the output
    +      Its sum
     ?     is the input
      !    Don't try any further possibilities
       ∧   Break unification with the output
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), ~~73~~ ~~68~~ ~~65~~ ~~56~~ ~~43~~ ~~42~~ 35 bytes
```
Range@#/.{___,x__,___}/;+x==#:>{x}&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@z8oMS891UFZX686Pj5epwKIgXStvrV2ha2tspVddUWt2v@Aosy8kmhlBV07hbRo5dhYBTUFfQeFagsdBUsdBSPT2v8A "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 61 41 bytes
```
h:{i{x':y}\:i:1+!x}
f:{i@*|&x=+/'i:,/h@x}
```
[Try it online!](https://ngn.codeberg.page/k#eJzLsKrOrK5Qt6qsjbHKtDLUVqyo5UoDijlo1ahV2Grrq2da6ehnOABFudIcLIHYAoiNTAHi4g/Z)
*¯20 bytes thanks to @doug*
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), ~~27~~ 26 bytes
```
{*|(x=+/')#{y+!'x}.1+!2#x}
```
[Try it online!](https://ngn.codeberg.page/k#eJxLs6rWqtGosNXWV9dUrq7UVlSvqNUz1FY0Uq6o5eIyUjBWMKlLU7Dk0tCx0AQyLLiAAgqmCmYK5kCekSkA+roO4A==)
Uses [doug's insight](https://chat.stackexchange.com/transcript/message/62011611#62011611) that to get a run you just need a pair of numbers.
[Answer]
# MATLAB, ~~87~~ 79 bytes
I know there is already a MATLAB answer, but this one is significantly different in approach.
```
x=input('');m=1:x;n=.5-m/2+x./m;l=max(find(~mod(n(n>0),1)));disp(m(1:l)+n(l)-1)
```
This also works on **Octave**. You can [try online here](http://octave-online.net/?s=QHPazBNGkfyhbhbdFrYAnJeGZmDvKMKYapOgHyikJRbmUTQP). I've already added the code to `consecutiveSum.m` in the linked workspace, so just enter `consecutiveSum` at the command prompt, then enter the value (e.g. 25).
I am still working on reducing it down (perhaps adjusting the equation used a bit), but basically it finds the largest value `n` for which `m` is an integer, then displays the first `m` numbers starting with `n`.
So why does this work? Well basically there is a mathematical equation governing all those numbers. If you consider that they are all consecutive, and start from some point, you can basically say:
```
n+(n+1)+(n+2)+(n+3)+...+(n+p)=x
```
Now, from this it becomes apparent that the sequence is basically just the first `p` triangle numbers (including the 0'th), added to `p+1` lots of `n`. Now if we let `m=p+1`, we can say:
```
m*(n+(m-1)/2)==x
```
This is actually quite solvable. I am still looking for the shortest code way of doing it, I have some ideas to try and reduce the above code.
---
For an input of 25, the output would be:
```
3     4     5     6     7
```
[Answer]
# awk, 51 bytes
```
{while($0!=s+=s<$0?++j:-++i);while(++i-j)r=r i"+"}$0=r j
```
The code is 56 bytes, minus 5 bytes for the output format. I had to use 4 extra bytes to produce that format, so I actually saved 1 byte. Hooray! ;)
It's actually doing the hard work of summing up starting from 1 until the sum is bigger than the input. Then it begins substracting numbers starting from 1 until the number is smaller than the input. It keeps changing the start and end number this way until it found a result, which it then prints.
## Usage example
```
echo 303 | awk '{while($0!=s+=s<$0?++j:-++i);while(++i-j)r=r i"+"}$0=r j'
```
## Output of example
```
48+49+50+51+52+53
```
I've tried this for an input of `1e12` and it gave the correct result (`464562+...+1488562`) almost immediately. Though it took a while printing it of course...
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
ẆS⁼¥Ðf⁸Ṫ
```
[Try it online!](https://tio.run/nexus/jelly#ARgA5///4bqGU@KBvMKlw5Bm4oG44bmq////MjU "Jelly – TIO Nexus")
If I understand correctly, this could be an (11-5=6)-byte version:
```
ẆS⁼¥Ðf⁸Ṫj”+
```
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), ~~64 62~~ 51 bytes
*-2 bytes thanks to Steffan*
*-11 bytes thanks to [Razetime's tip](https://codegolf.stackexchange.com/a/251862/76162)*
```
N+Z:-numlist(1,N,A),append([_,Z,_],A),sumlist(Z,N).
```
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/3087yko3rzQ3J7O4RMNQx0/HUVMnsaAgNS9FIzpeJ0onPhYkUgxVEKXjp6n3/7@ltqMeF5cFmDQDk0amQAoA "Prolog (SWI) – Try It Online")
[Answer]
## [Pyth](https://github.com/isaacg1/pyth), 12 - 5 = **7 bytes**
```
j\+efqQsT.:S
```
[Test suite](https://pythtemp.herokuapp.com/?code=j%5C%2BefqQsT.%3AS&test_suite=1&test_suite_input=9%0A8%0A25&debug=0)
The existing Pyth answer uses an older version of the language; new features have been added since.
##### Explanation:
```
j\+efqQsT.:S  | Full code
j\+efqQsT.:SQ | with implicit variables
--------------+----------------------------------------------------
           SQ | Get the range [1, ... input]
         .:   | Get all substrings, sorted by length
    f         | Filter for T such that
       sT     |  the sum of T
     qQ       |  equals the input
   e          | Get the last (longest) element of the filtered list
j\+           | Join by "+"
```
[Answer]
# Python 2, 94 bytes
```
n=input()
r=int((2*n)**.5)
while r:
 if~r%2*r/2==n%r:print range(n/r-~-r/2,n/r-~r/2);r=1
 r-=1
```
Input is taken from stdin. This solution is suitable for very large inputs.
This iterates over the possible solution lengths, *r*, having *r ≤ √(2n)*, and checks for a solution explicitly. In order for a solution to exist, if *r* is odd, *n mod r* must be zero, and if *r* is even, *n mod r* must be *r/2*.
---
**Sample Usage**
```
$ echo 8192 | python sum-con-int.py
[8192]
$ echo 1000002 | python sum-con-int.py
[83328, 83329, 83330, 83331, 83332, 83333, 83334, 83335, 83336, 83337, 83338, 83339]
$ echo 1000000006 | python sum-con-int.py
[250000000, 250000001, 250000002, 250000003]
```
I've deliberately choosen examples with relatively small outputs.
[Answer]
# Octave, 89 Bytes
This is the best I could do in Octave. The algorithm is the same as xnor's.
```
x=input('');k=i=1;while x;s=sum(k:i);if s<x;i++;elseif s>x;k++;else;x=0;end;end;disp(k:1)
```
In MATLAB this would be 95 bytes:
```
x=input('');k=1;i=1;while x;s=sum(k:i);if s<x;i=i+1;elseif s>x;k=k+1;else x=0;end;end;disp(k:i)
```
In MATLAB this runs in approx 0.1 seconds for input `2000000` and 1 second for input `1000002`.
[Answer]
# PHP, 70 bytes
```
while(fmod($q=sqrt(2*$argn+(++$p-.5)**2)-.5,1));print_r(range($p,$q));
```
Run as pipe with `-nR` or [try it online](http://sandbox.onlinephpfunctions.com/code/69c2ba6fc0aa0f2edd8b21c20b22375464bbd59c).
increments `p` until it finds an integer solution for `argument==(p+q)*(q-p+1)/2`,  
then prints the range from `p` to `q`.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 12 - 5 = 7 bytes
```
J'+msḟo=¹ΣQḣ
```
[Try it online!](https://tio.run/##ARwA4/9odXNr//9KJyttc@G4n289wrnOo1HhuKP///84 "Husk – Try It Online")
Removing the first 5 bytes for joining, it still scores the same.
## Explanation
```
J'+msḟo=¹ΣQḣ
           ḣ range from 1..n
          Q  all possible sublists
     ḟ       get the first value which satisfies:
       =¹Σ   sum = input.
   ms        convert each number to string
J'+          join on '+'
```
[Answer]
# Knight, 66 bytes
```
;=i+=a 0P W;=r""!>=a+1=b a=c iW!>0c;=c-c=b+1b;=r+r+"+"bI?0cQ Or 0 
```
[Try it online!](https://tio.run/##rVltc9pIEv4Mv2IgZdCASCTZW7UHFpSTtVOudezETjYfbC4WQtiqE4KThL1ex/vXs909LxoBzl3u1h8Qmnm6p/uZnu4eHPZuwvDbizgNk9U02s@Labx4eTusmyNJPKkMhcXDMloDZXF6Uxkq4rnATKNZnEYsSViySG/oo65HP55@esfc8vXi4znzytffDs7ZXvl6dPqG/Vy@nn9ibgk@OrkwsKefTgzop9N3Bxe/WjlnFn602J/uT1zPHlzAsmIyvA0y1uGlgIkCW7WK4ZDtlXOnh59xMoVJ8ugrw@/7@2sYXIYw6CZgkoQjsIJ5fXZ2QiD8GJGTffTNMOT8rQCAvGHrXZCsIs4v0zGv18kP2JXLsX/ePDw7sr4N/LjrB8x5zz4P/KzZbAz9oOv6Exb4IYs/N4ZOOPDDXuhPuu4EEN2s2@w2J8cjJ/z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18AK/TaRJN2XVp9rXW8ojfRGNmLFI6M0RlvZ565wSvSWjHMP1J58F9Cta1wodJr5IX/WpWHDHz8O@bxwBF@/I3uhYTgBGrNIo0aDMjG6IOR0iqkuuJOoDYhg/VxuiChnAoMbQW00WfzaN5uMQwS9nwevT/ujL8G1wZKlcaW3zxpS/SldHz7ItVt5iM0yNWAXga4akC2thmZ/mi3VOZx1SgzWuV6Q992VYbRqakTCVa/ut/Iy9zkKFGyw/afRNdaXPXsX6ZdavTP3yRUb1teZNBXK1ym9GpkDCocexXpI00iRKI6Ha1mDD5M7gnfvUyG82Kd8zsXaTYcbVrR6ghP/L6uwYtb8WVwTc6rK5ZgDbvSKm8eNj6LOxWGtoLQfSa0sF6yfO2lbxdrvsAT0vv0eB/aIjQMHziVoS6@dftkNkbeeAhrtp1sUmiBkHEv5ikByG68iTA6tNoFkCSBM9UhxmnMBlP6UekICygTLV3wjb2nDjC2TO3WFSmayB0g/KHhHkQp9issiC7CW1S2unA9zuOP1fR/RL/5WM5ZE31Gvf07R9/AQ "C (gcc) – Try It Online")
Annotated code:
```
;=i+ =a 0 PROMPT                        # set a to 0, i to input
WHILE ;=r "" !>(=a +1(=b a)) (=c i)     # set r to "", b to a, a to a+1, c to i, check if a less than c
  WHILE !< c 0                          # while c >= 0:
    ;=c (-c (=b +1b))                   # set b to b+1, c to c-b
    ;=r (+ r + " " b)                   # append b to r
    IF (? c 0) (QUIT OUTPUT r) 0        # if c is 0, output r and break; else, do nothing
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 11 - 5 = 6 bytes
Taking that bonus of course :)
```
LŒʒOQ}é¤'+ý
```
[Try it online!](https://tio.run/nexus/05ab1e#@@9zdNKpSf6BtYdXHlqirn147///RqYA "05AB1E – TIO Nexus")
```
LŒʒOQ}é¤'+ý  Argument: n
LŒ           Sublists of range 1 to n
  ʒOQ}       Filter by total sum equals n
      é¤     Get longest element
        '+ý  Join on '+'
```
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 72 bytes
```
L/X/H:-between(L,H,X).
N*Z:-1/A/N,A/X/N,findall(Y,A/Y/X,Z),sumlist(Z,N).
```
[Try it online!](https://tio.run/##DcqxCoAgFEDRva9w1Hj2KGhpCbeGcDa3IgvBNNLo883xHu79BBdOHj@b84wKp4FvJn3GeDrDBIo1laz1wFsUKEGUQ8Jh/b46R5fSCyrQDOJ7ORsT1SBZk0dOup7URAC5H@sTFQV/ "Prolog (SWI) – Try It Online")
-4 bytes thanks to DLosc.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 66 bytes
```
i,j;f(n){for(i=j=0;n;)n+=n>0?--j:++i;for(;i+j;)printf("%d ",++i);}
```
Inspired by xnor's sliding window solution, keeps track of the ends of the window.
[Try it online!](https://tio.run/##TU5LDoMgEF3DKQhNGwjS2G0p9iwGtA6xo/HTLoxnp@Cqs3mTeb9x@uVcjFAE0wqUWztMAmywpUEjUVmsyqfW4a4UmMwZUMHIcQJcWsHPnvEiUdLs8QTo@tU37DEvHoZrV1GaVPRdA4rPAF7SjZJ0YWgo@XbQN2J2NR4xvGAXlMxadpMsychfg65SCUOZXCT/mHFcl1lwnved7vFWHvMD "C (gcc) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), (10-5=) 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Åœ.Δ¥P}'+ý
```
[Try it online](https://tio.run/##yy9OTMpM/f//cOvRyXrnphxaGlCrrn147///RqYA) or [verify all test cases](https://tio.run/##AS4A0f9vc2FiaWX/dnk/IiDihpIgIj95/8OFxZMuzpTCpVB9JyvDvf8s/1s5LDgsMjVd).
**Explanation:**
```
Åœ        # Get all lists of positive integers that sum to the (implicit) input,
          # which is sorted from longest (all 1s) to shortest (just the number)
  .Δ      # Find the first list which is truthy for:
    ¥     #  Get the deltas/forward-differences of the list
     P    #  Take the product (only 1 is truthy in 05AB1E)
   }'+ý  '# After we've found a list: join it with "+" delimiter
          # (after which it is output implicitly as result)
```
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2), 10 - 5 = 5 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
RƑæS=;h'+j
```
[Try it online!](https://Not-Thonnu.github.io/run#aGVhZGVyPSZjb2RlPVIlQzYlOTElQzMlQTZTJTNEJTNCaCclMkJqJmZvb3Rlcj0maW5wdXQ9OSZmbGFncz0=)
Port of tybocopperkettle's Vyxal answer.
#### Explanation
```
RƑæS=;h'+j  '# Implicit input
RƑ           # All sublists of [1..n]
  æ  ;       # Filtered by:
   S=        #  Sum equals input
      h      # First item
       '+j  '# Joined by "+"
             # Implicit output
```
[Answer]
# [Japt](https://github.com/ETHproductions/Japt), 33 bytes
This uses [Dennis's Pyth technique](https://codegolf.stackexchange.com/a/66222/42545), although it's considerably longer...
```
1oU à2 £W=Xg o1+Xg1¹x ¥U©W} rª ªU
```
[Try it online!](http://ethproductions.github.io/japt?v=master&code=MW9VIOAyIKNXPVhnIG8xK1hnMbl4IKVVqVd9IHKqIKpV&input=MTg=) **Warning:** For larger inputs (<= 20), it takes a while to finish, and freezes your browser until it does.
### Ungolfed and explanation
```
1oU à2 £    W=Xg o1+Xg1¹ x ¥ U© W} rª  ª U
1oU à2 mXYZ{W=Xg o1+Xg1) x ==U&&W} r|| ||U
          // Implicit: U = input integer
1oU à2    // Generate a range from 1 to U, and take all combinations of length 2.
mXYZ{     // Map each item X in this range to:
W=Xg o    //  Set variable W to the range of integers starting at the first item in X,
1+Xg1)    //  and ending at 1 + the second item in X.
x ==U&&W  //  If the sum of this range equals U, return W; otherwise, return false.
r||       // Reduce the result with the || operator, returning the first non-false value.
||U       // If this is still false, there are no consecutive ranges that sum to U,
          // so resort to U itself.
          // Implicit: output last expression
```
Bonus-earning version: (38 bytes - 5 = 33)
```
1oU à2 £W=Xg o1+Xg1¹x ¥U©W} rª ªU² q'+
```
[Answer]
# Julia, 92 bytes
```
x->(t=filter(i->all(j->j==1,diff(sort(i))),partitions(x));collect(t)[indmax(map(length,t))])
```
This is an anonymous function that accepts an integer and returns an array. To call it, give it a name, e.g. `f=x->...`.
Ungolfed:
```
function f(x::Integer)
    # Get all arrays of integers that sum to x
    p = partitions(x)
    # Filter these down to only consecutive runs by checking whether
    # all differences are 1
    t = filter(i -> all(j -> j == 1, diff(sort(i))), p)
    # Find the index of the longest element of t
    i = indmax(map(length, t))
    return collect(t)[i]
end
```
[Answer]
# Ruby, 94 bytes
```
->n{([*1..n].permutation(2).map{|i,j|[*i..j]if(i..j).reduce(:+)==n}-[p]).max_by{|k|k.size}||n}
```
**Ungolfed:**
```
-> n {
  ([*1..n].permutation(2).map { |i,j|   # Finds all the possible sets of size 2
     [*i..j] if(i..j).reduce(:+) == n   # Adds a set to an array if sum of the set is n.
   }-[p]                                # Removes nil from the array
  ).max_by { |k|                        # Finds the longest sequence
    k.size
  } || n                                # Returns n if no sequence found.
}
```
**Usage:**
```
->n{([*1..n].permutation(2).map{|i,j|[*i..j]if(i..j).reduce(:+)==n}-[p]).max_by{|k|k.size}||n}[25]
=> [3, 4, 5, 6, 7]
```
[Answer]
## Seriously, 53 - 5 = 48 bytes
```
,;;;╝`;u@n╟(D;)`n(XXk`iu@u@x;Σ╛=[])Ii`╗`ñ╜M`M;░p@X'+j
```
Hex Dump
```
2c3b3b3bbc603b75406ec728443b29606e2858586b60697540754
0783be4be3d5b5d29496960bb60a4bd4d604d3bb0704058272b6a
```
[Try It Online!](http://seriouslylang.herokuapp.com/link/code=2c3b3b3bbc603b75406ec728443b29606e2858586b606975407540783be4be3d5b5d29496960bb60a4bd4d604d3bb0704058272b6a&input=15)
It's the brute force approach, similar to Dennis's Pyth. 
Everything up to the `k` just reads input `n` into register 1 and then creates the list `[[1],[2,2],[3,3,3],[4,4,4,4],...]` up to `n` `n`'s. 
The next bit up to `╗` is a function stored in register 0 that takes a pair, increments both elements, converts them to a range, finds the sum of the range, and checks whether that sum is the value in register 1. If it is, it returns the corresponding range, and if it's not, it returns an empty list. 
The part up to the last occurrence of `M` maps a function over the fancy list of lists described above, doing `enumerate` on each list, then mapping the stored function over it. When it is done, we have a list of lists each of which is empty or a range which sums to `n`.
`;░` removes the empty lists. `p@X` takes the first list which remains (`0@E` would also work). `'+j` puts `+` between each number as it converts the list to a string for the bonus.
[Answer]
## ES6, 72 bytes
```
n=>{for(l=u=1;n;)n>0?n-=u++:n+=l++;return[...Array(u).keys()].slice(l);}
```
Straight port of @Cabbie407's awk solution, but without the formatting bonus, since it's a penalty here.
]