Inrecreational mathematics, aKeith number orrepfigit number (short forrepetitiveFibonacci-like digit) is anatural number in a givennumber base with digits such that when a sequence is created such that the first terms are the digits of and each subsequent term is the sum of the previous terms, is part of the sequence. Keith numbers were introduced byMike Keith in 1987.[1]They are computationally very challenging to find, with only about 100 known.
Let be a natural number, let be the number of digits of in base, and let
be the value of each digit of.
We define the sequence by alinear recurrence relation. For,
and for
If there exists an such that, then is said to be aKeith number.
For example, 88 is a Keith number inbase 6, as
and the entire sequence
and.
Whether or not there are infinitely many Keith numbers in a particular base is currently a matter of speculation. Keith numbers are rare and hard to find. They can be found by exhaustive search, and no more efficient algorithm is known.[2]According to Keith, inbase 10, on average Keith numbers are expected between successivepowers of 10.[3] Known results seem to support this.
14,19,28,47,61,75, 197, 742, 1104, 1537, 2208, 2580, 3684, 4788, 7385, 7647, 7909, 31331, 34285, 34348, 55604, 62662, 86935, 93993, 120284, 129106, 147640, 156146, 174680, 183186, 298320, 355419, 694280, 925993, 1084051, 7913837, 11436171, 33445755, 44121607, 129572008, 251133297, ...[4]
Inbase 2, there exists a method to construct all Keith numbers.[3]
The Keith numbers inbase 12, written in base 12, are
where ᘔ represents 10 and Ɛ represents 11.
A Keith cluster is a related set of Keith numbers such that one is a multiple of another. For example, inbase 10,,, and are all Keith clusters. These are possibly the only three examples of a Keith cluster inbase 10.[5]
The example below implements the sequence defined above inPython to determine if a number in a particular base is a Keith number:
defis_repfigit(x:int,b:int)->bool:"""Determine if a number in a particular base is a Keith number."""ifx==0:returnTruesequence=[]y=xwhiley>0:sequence.append(y%b)y=y//bdigit_count=len(sequence)sequence.reverse()whilesequence[len(sequence)-1]<x:n=0foriinrange(0,digit_count):n=n+sequence[len(sequence)-digit_count+i]sequence.append(n)returnsequence[len(sequence)-1]==x