+ 6

# Keith number

Is it possible to make a program in java to check whether the entered number is keith number or not without using array? A n digit number x 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 x and other terms are recursively evaluated as sum of previous n terms. Input : x = 197 Output : Yes 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, ..... Input : x = 12 Output : No The number is not Keith because it doesn't appear in the special sequence generated using its digits. 1, 2, 3, 5, 8, 13, 21, ..... Input : x = 14 Output : Yes 14 is a Keith number since it appears in the sequence, 1, 4, 5, 9, 14, ...

12th Jan 2019, 2:18 AM
mn121
+ 1
https://code.sololearn.com/cKeCv3X81Cf5/?ref=app I used int for the sum and String to store the needed numbers.
12th Jan 2019, 8:44 PM
Denise RoĂberg
5th Aug 2019, 10:34 AM
Mritunjay Kumar
+ 3
Hi! Can you mention what a keith number is? It is possible to solve anything in programming. so don't worry, your question has an answer
12th Jan 2019, 5:07 PM
Seniru
+ 1
Denise Roáșberg Thanks... đđ
13th Jan 2019, 12:51 PM
mn121
0
I would say the trick is to remove the first number if you have the sum. 197: 1 + 9 + 7 = 17 9 + 7 + 17 = 33 7 + 17 + 33 = 57 17 + 33 + 57 = 107 33 + 57 + 107 = 197 If sum = input --> keith number If sum > input --> not a keith number It is like a fibonacci sequence.
12th Jan 2019, 9:07 PM
Denise RoĂberg