I haven't given an explicit formula at present which is why I am saying that. The answer is the number of odd factors of n other than 1.
Because I am lazy, I wrote a quick script to merely show these work, i.e. do this for me and I have some examples using the numbers from Swammerdami's post. This isn't meant to be a proof.
42:
Odd factors: 3, 7, 21
-----------------------------------------
k=3 (p=14): 13 + 14 + 15 = 42
k=7 (p=6 ): 3 + 4 + 5 + 6 + 7 + 8 + 9 = 42
k=21 (p=2 ): 9 + 10 + 11 + 12 = 42
180:
Odd factors: 3, 5, 9, 15, 45
-----------------------------------------
k=3 (p=60): 59 + 60 + 61 = 180
k=5 (p=36): 34 + 35 + 36 + 37 + 38 = 180
k=9 (p=20): 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 = 180
k=15 (p=12): 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 = 180
k=45 (p=4 ): 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 = 180
1440:
Odd factors: 3, 5, 9, 15, 45
-----------------------------------------
k=3 (p=480): 479 + 480 + 481 = 1440
k=5 (p=288): 286 + 287 + 288 + 289 + 290 = 1440
k=9 (p=160): 156 + 157 + 158 + 159 + 160 + 161 + 162 + 163 + 164 = 1440
k=15 (p=96): 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 + 100 + 101 + 102 + 103 = 1440
k=45 (p=32): 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 = 1440
138:
Odd factors: 3, 23, 69
-----------------------------------------
k=3 (p=46): 45 + 46 + 47 = 138
k=23 (p=6 ): 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 = 138
k=69 (p=2 ): 33 + 34 + 35 + 36 = 138
Let me now try to respond to some of Swammerdami's post, but my response will probably be too basic.
The number of terms is either even (k=2x) or odd (k=2x+1).
The number of terms pre-cancellation is always odd. After cancellation, it may be either odd or even. This is dependent upon the parity of n. The sum of two consecutive positive numbers is always odd and likewise for the sum of an even number of consecutive numbers. Meanwhile, the sum of an odd number of consecutive numbers is always even. So, post-cancellation, when we have only positive numbers, all even sums have only an odd number of terms and all odd sums have only an even number of terms.
Failure type 1 Example: 1440=32*3*3*5 (Too many 2's to cope with the largest odd factor)
The product of all the odd factors may be too small relative to twice the power-of-two residue. Extrapolating from the first line in the 180 example. we see that eventually the five predicted solutions shrink to 4:
45 :: k=2⋅1+0 ; b=21 = (45/1 - 2 - 1)/2 =====> 22+23
90 :: k=2⋅2+0 ; b=20 = (90/2- 4 - 1)/2 =====> 21+22+23+24
180 :: k=2⋅4+0 ; b=18 = (180/4 - 8 - 1)/2 =====> 19+20+...+26
360 :: k=2⋅8+0 ; b=14 = (360/8 - 16 - 1)/2 =====> 15+16+...+30
720 :: k=2⋅16+0 ; b=6 = (720/16 - 32 - 1)/2 =====> 7+8+...+38
1440 :: k=2⋅32+0 ; b=-10 = (1440/32 - 64 - 1)/2 =====> FAILURE: b negative
But note that, via the cancellations -9-8-...0+1+2+...+9 = 0 the (failing) sum of an even number of consecutive terms can be rewritten to be a redundant derivation of the longest odd-length sum!
1440 :: k=2⋅22+1 ; b=9 = (1440/45 - 22 - 1) =====> 10+11+...+54
But we can't count that solution twice!
This is interesting. It makes me wonder if extrapolating this at all is correct. Perhaps something else should be extrapolated. I simply don't know. Therefore, as an exercise, I will record the number of terms for each sequence for each sum. This way we can look for patterns.
Number of terms in each sequence. I have pre and post cancellation separated by -->.
45: 3, 5, 9, 15-->6, 45-->2
90: 3, 5, 9, 15-->12, 45-->4
180: 3, 5, 9, 15, 45-->8
360: 3, 5, 9, 15, 45-->16
720: 3, 5, 9, 15, 45-->32
1440: 3, 5, 9, 15, 45
My interpretation of the pattern (which we also see with 15) is that when the center is sufficiently low, the pre-cancellation sequence will contain negative numbers. If we keep multiplying by 2 (or some other prime), the center moves out of range so that the terms' bottom exceeds 0 and then the pre and post numbers are the same. Using variables from before k is the number of pre-cancellation terms. k is odd and can be expressed as 2x+1. p = n/k. So, if p-x <=0, there are negative terms. We can rewrite this many ways probably and some ways may be more insightful. p<= x for example or n/k <= (k-1)/2.
Or if we take the opposite, i.e. when pre = post, we could say n > k(k-1)/2. Let's check that for this case. n = 1440. k = 45; 1440 > 990. But for n=720, 720 < 990. **[990 is 45 x 44 / 2]
I apologize for using different meanings to same variable names that Swammerdami. This may make it confusing. Also, I know I haven't answered everything here.