<p>Given an integer <code>n</code>, return <em>the number of ways you can write </em><code>n</code><em> as the sum of consecutive positive integers.</em></p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> n = 5
<strong>Output:</strong> 2
<strong>Explanation:</strong> 5 = 2 + 3
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> n = 9
<strong>Output:</strong> 3
<strong>Explanation:</strong> 9 = 4 + 5 = 2 + 3 + 4
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> n = 15
<strong>Output:</strong> 4
<strong>Explanation:</strong> 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= n &lt;= 10<sup>9</sup></code></li>
</ul>

class Solution:
    def pd(self, i):
        if i == 1:
            return True
        if i % 2 > 0:
            if self.n % i != 0:
                return False
            mid = self.n // i
            return mid > i // 2
        if self.n % (i//2) != 0 or self.n % i == 0:
            return False
        mid = self.n // i
        return mid >= i // 2

    def consecutiveNumbersSum(self, n: int) -> int:
        self.n = n
        #print(self.pd(1),self.pd(2),self.pd(3),self.pd(5))
        rst = 0
        for i in range(1, n+1):
            if i * i > 4 * n:
                break
            if self.pd(i):
                rst += 1
        return rst
        
16600