Hey,
I've been doing this little program to check if a number is a Keith number, and for some reason it's not working. I've gone over the code a few times but still can't detect the error. Could you please help?
static boolean isKeith(int n)
{
int sz=Func.sumDg(n);
int arr[]=new int[sz];
int i=0,k=n;
while(n>0)
{
arr[i]=n%10;
i++;
n/=10;
}
Disp.shw1D(arr);
int sum=Func.sumArr(arr);
while(sum<k)
{
for(int j=0;j<sz-1;j++)
{
arr[j]=arr[j+1];
}
arr[sz-1]=sum;
if(sum==k) return true;
sum=Func.sumArr(arr);
}
return false;
}
Thanks in advance...