the following program is to print all possible sum combinations of a number
for example
6=1+5,2+4,3+3,1+1+4,1+2+3
12=3+9,4+8,5+7,.......,1+1+2+3+5
but i m not getting any output...maybe there's a problem with proper ending of loops
pls help
import java.io.*;
public class sumpermutations
{
public void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int input,i,j,d=0,s=0,num=0,d1=0;
System.out.println("ENTER NUMBER");
input=Integer.parseInt(br.readLine());
for(i=1;i<=99999;i++)//for loop till the highest 5 digit number
{
while(i!=0)//to find the sum of digits of each number
{
num=i;
d=i%10;
s+=d;
i/=10;
}
if(s==input)//checks if the sum is equal to the input number
{
if(istrue(num))//function to check if the digits of num are in ascending order
{
d1=num%10;
System.out.print(d1+"+");//if so print the digits which is the sumcombination of the input number
num/=10;
}
}
}
}
public boolean istrue(int n)
{
int i,j,k=0,di=0,c=0;boolean res=false;int arr[]=new int[6];
while(n!=0)
{
di=n%10;
c++;
arr[k]=di;//store the digits in array
n/=10;
k++;
}
for(i=0;i<arr.length-1;i++)
{
if(arr[i]<arr[i+1])//checks if the array is in ascending order
{
res=true;
return res;//if so then return true
}
else//else false
{
res=false;
return res;
}
}
return res;
}
}