title: Given a number N, find the number of ways to write it as a sum of two or more consecutive integers
body: <p>Here is the <a href="http://yodacode.com/content/sumOfIntegers1" rel="nofollow">problem</a> that tagged as <em>dynamic-programming</em> (Given a number N, find the number of ways to write it as a sum of two or more consecutive integers) and example 15 = 7+8, 1+2+3+4+5, 4+5+6</p>
  
  <p>I solved with math like that :</p>
  
  <p>a + (a + 1) + (a + 2) + (a + 3) + ... + (a + k) = N <br></p>
  
  <p>(k + 1)*a  + (1 + 2 + 3 + ... + k) = N <br></p>
  
  <p>(k + 1)<em>a + k</em>(k+1)/2 = N <br></p>
  
  <p><strong>(k + 1)*(2*a + k)/2 = N</strong> <br></p>
  
  <p>Then check that if N divisible by (k+1) and (2*a+k) then I can find answer in O(sqrt(N)) time</p>
  
  <p>Here is my question how can you solve this by <em>dynamic-programming</em> ? and what is the complexity (O) ? <br> <br></p>
  
  <p>P.S : excuse me, if it is a duplicate question. I searched but I can find</p>