Given an integer

*n* (

*n*≠0), there are a finite number of sequences of consecutive integers whose terms add up to

*n* (If

*n*=25, then 3+4+5+6+7=25 is one such sequence with 5 terms).

a. Find an equation for the number of terms of the longest such sequence for any positive integer

*n*.

b. Find equations for the bounds (the first and last terms) of the longest such sequence for any positive integer

*n*.

**Hint:** Once you have an equation for the number of terms, and for the first term of the sequence, the last term is simply one less than their sum.

**Hint 2:** Ducks have absolutely nothing to do with the problem.

If a number can be factored as p times q, and p is odd, then

n = (q-(p-1)/2) + ... + (q-1) + q + (q+1) + ... + (q+(p-1)/2)

Should the first term be negative, the first terms would cancel each other (as in 5=-1+0+1+2+3) and you would have

n = (-q+(p+1)/2) + ... + (q-1) + q + (q+1) + ... + (q+(p-1)/2)

The longest sequence could be the largest odd factor of n.

The last term would the the largest value of (q+(p-1)/2), as seen above.

As a remark, you can deduce which numbers do *not* allow such a sequence...

PS. If p is odd and q is even, you can also write

n = (p-q+1)/2 + .... (p-1)/2 + (p+1)/2 + ... + (p+q-1)/2

Some of the negative terms (if present) could cancel out some positive terms. The length of this sequence is q, and the maximum term, (p+q-1)/2.