Question

# Check whether a number  is Keith number.A number is called Keith number if it appears in a special sequence (defined below) generated using its digits. The special sequence has first n terms as digits of number and other terms are recursively evaluated as sum of previous n terms

```				```
ENTER A NUMBER:
197
197 is a keith number

197 has 3 digits, so n = 3
The number is Keith because it appears in the special
sequence that has first three terms as 1, 9, 7 and
remaining terms evaluated using sum of previous 3 terms.
1, 9, 7, 17, 33, 57, 107, 197, .....
```
```

# Share code with your friends

Code

```				```
import java.util.Scanner;

public class keithNumber
{
public static void main()
{
int digits[];
int num=0,count=0,i=0,temp=0,sum=0;
Scanner sc=new Scanner(System.in);
System.out.println("ENTER THE NUMBER");
num=sc.nextInt();
temp=num;
while(temp>0)
{
count++;
temp=temp/10;
}
digits=new int[count];
System.out.println(count);
temp=num;
while(temp>0)
{
digits[count-1]=temp%10;
temp/=10;
count--;
}

while(sum< num)
{
sum=0;
for(i=0;i< digits.length;i++)
{
sum=sum+digits[i];

}
for(i=0;i< digits.length-1;i++)
{
digits[i]=digits[i+1];
}
digits[digits.length-1]=sum;

}

if(sum==num)
{
System.out.println(num+" is keith number");
}
else
{
System.out.println(num+" is not a keith number");
}
}
}

```
```

## Coding Store

Sale ### Mastering String

50
Sale 150
Sale 200
Sale ### Mastering Recursion

50
Sale ### Mastering Numbers

50
Sale ### Mastering Matrix

50
Sale ### Mastering Array

50
Sale ### ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)

50
Sale 50