 ## An n digit number M is called Keith number if it appears in a special sequence generated using its digits.

#### For more number programs click the linkhttps://java4school.com/important-number-programs-icse-part-4

Write a program to accept a number and print whether it is a keith number or not.

``````FOR EXAMPLE: 746, 404, 219 etc
import java.io.*;
class Keith //An n-digit number with value N is Keith if N is a part of Keith series generated
{
public static void main()throws IOException
{
System.out.println("Enter the number");
int len=num.length();
int nm=Integer.parseInt(num);
int arr[]=new int[len];
int n=nm;
for(int i=0;i<len;i++)
{
int d=n%10;
n/=10;
arr[len-1-i]=d;
}
for(int i=0;i<len;i++)
{
System.out.println(arr[i]);
}
int sum=0,count=0;
while(sum<nm)
{
sum=0;
for(int i=0;i<len;i++)
{
sum+=arr[i];
}
arr[count]=sum;
count++;
if(count>(len-1))
{
count=0;
}
}
if(sum==nm)
{
System.out.println("It is a Keith number");
}
else
{
System.out.println("Not a Keith number");
}
}
}
``````

Output:
Enter the number
197
It is a Keith number