title: Represent an Integer as a sum of Consecutive positive integers
body: <p>I am writing code for counting the number of ways an integer can be represented as a sum of the consecutive integers. For Example</p>
  
  <p>15=(7+8),(1+2+3+4+5),(4+5+6). So the number of ways equals 3 for 15.
  Now the input size can be &lt;=10^12. My program is working fine till 10^7(i think so, but not sure as i didnt check it on any online judge. Feel free to check the code for that)</p>
  
  <p>but as soon as the i give it 10^8 or higher integer as input. it throws many runtime exceptions(it doesnt show what runtime error). Thanks in advance.</p>
  
  <pre><code>import java.io.*;
  
  //sum needs to contain atleast 2 elements
  public class IntegerRepresentedAsSumOfConsecutivePositiveIntegers
  {
      public static long count = 0;
      public static void main(String[] args) throws IOException
      {
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          long num = Long.parseLong(br.readLine()); //Enter a number( &lt;=10^12)
          driver(num);
          System.out.println("count = " + count);
      }
  
      public static void driver(long num)
      {
          long limit = num / 2;
          for(long i = 1 ; i &lt;= limit ; i++)
          {
              func(i,num);
          }
      }
  
      public static void func(long i,long num)
      {
          if(i &lt; num)
          {
              func(i + 1,num - i);
          }
          else if(i &gt; num)
          {
              return;
          }
          else
          {
              count++;
          }
      }
  
  }
  </code></pre>