The question states : "Write a program which inputs a positive natural number N and prints the possible consecutive number combinations, which when added give N".

For example :

N=9

Output :

2 3 4

4 5

Another Example:

N=27

Output:

2 3 4 5 6 7

8 9 10

13 14

Here's my source code :

import java.io.*;

class neutral

{

int N;

void main()throws IOException

{

BufferedReader br = new BufferedReader (new InputStreamReader (System.in));

System.out.println("Enter a Number:");

N=Integer.parseInt(br.readLine());

int arr[]=new int[N];

int no=1;

int f=0;

int r=f;

int sum=0;

for(int i=0; i<N; i++)

{

arr[i]=no;

no++;

}

for(f=0; f<N; f++)

{

for(r=f; r<N; r++)

{

sum=sum+arr[r];

if(sum==N)

{

break;

}

}

if(sum==N)

{

break;

}

}

for(int k=f; k<r; k++)

{

System.out.println(arr[k]+" ");

}

}

}

=========================

It accepts the number but gives no output.

Can you please verify the errors, correct it, and tell me where I went wrong.

Thanks. =)