Skip to main content

Posts

Showing posts from June, 2020

Keith Number

KEITH NUMBER Before  moving on to code let us talk about what is Keith number  . A number is said to be Keith Number , if  it appears in the sequence where first n numbers are digits of  number itself and rest are formed by repeatedly adding the previous n numbers of the sequence . It is illustrated in the example below: eg.  1. 14 is a Keith number          Sequence formed by 14 is  1, 4, 5, 9, 14, . . . .       First two numbers(1, 4) are digits of number(14)  itself and rest are formed by adding the  previous  two numbers of sequence(1+4=5, 5+4=9, 9+5=14).  2. 197 is a Keith number       Sequence formed by 197 is 1, 9, 7, 17,  33,  57, 107,  197 , . . . .      First three numbers(1, 9, 7) are digits of number(197)  itself and rest are formed by adding the  previous  two numbers of sequence(1+9+7=17, 9+7+17=33,  7+17+33=57 , 17...