C Numbers 35: Check if a number is a Keith Number [C Programming]

preview_player
Показать описание
Write a program in C to check if a number is Keith or not.

Expected Output :
Input a number : 1104
The given number is a Keith Number

What is a Keith Number?

Keith numbers are rare numbers with a Fibonacci like property. A n-digit number
with value N is a Keith number if N is part of the Keith series generated. The
series starts with the n digits of the number N. Then the subsequent numbers in the
series are found by calculating the sum of preceding n numbers. If the number
N appears in the series, it is called a Keith number. Keith numbers are
also known as repfigit (repetitive Fibonnaci-like digit) numbers. Keith are
very rare and computationally difficult to find.

For example consider the 3 digit number 742. Using the above rule, the first three
numbers are 7, 4, 2. The next one is 7+4+2 (adding 3 previous numbers) = 13. The
next one in the series is 4+2+13 = 19. By applying this rule, the following are
numbers in the sequence:
7, 4, 2, 13, 19, 34, 66, 119, 219, 404, 742, 1365. The original number appears
as the 11th item in the series. Hence the number 742 is a 3 digit Keith number

=================================================

Рекомендации по теме
welcome to shbcf.ru