In mathematics a polydivisible number (or magic number) is a number in a given number base with digits abcde... that has the following properties:[1]
Let n {\displaystyle n} be a positive integer, and let k = ⌊ log b n ⌋ + 1 {\displaystyle k=\lfloor \log _{b}{n}\rfloor +1} be the number of digits in n written in base b. The number n is a polydivisible number if for all 1 ≤ i ≤ k {\displaystyle 1\leq i\leq k} ,
For example, 10801 is a seven-digit polydivisible number in base 4, as
For any given base b {\displaystyle b} , there are only a finite number of polydivisible numbers.
The following table lists maximum polydivisible numbers for some bases b, where A−Z represent digit values 10 to 35.
Let n {\displaystyle n} be the number of digits. The function F b ( n ) {\displaystyle F_{b}(n)} determines the number of polydivisible numbers that has n {\displaystyle n} digits in base b {\displaystyle b} , and the function Σ ( b ) {\displaystyle \Sigma (b)} is the total number of polydivisible numbers in base b {\displaystyle b} .
If k {\displaystyle k} is a polydivisible number in base b {\displaystyle b} with n − 1 {\displaystyle n-1} digits, then it can be extended to create a polydivisible number with n {\displaystyle n} digits if there is a number between b k {\displaystyle bk} and b ( k + 1 ) − 1 {\displaystyle b(k+1)-1} that is divisible by n {\displaystyle n} . If n {\displaystyle n} is less or equal to b {\displaystyle b} , then it is always possible to extend an n − 1 {\displaystyle n-1} digit polydivisible number to an n {\displaystyle n} -digit polydivisible number in this way, and indeed there may be more than one possible extension. If n {\displaystyle n} is greater than b {\displaystyle b} , it is not always possible to extend a polydivisible number in this way, and as n {\displaystyle n} becomes larger, the chances of being able to extend a given polydivisible number become smaller. On average, each polydivisible number with n − 1 {\displaystyle n-1} digits can be extended to a polydivisible number with n {\displaystyle n} digits in b n {\displaystyle {\frac {b}{n}}} different ways. This leads to the following estimate for F b ( n ) {\displaystyle F_{b}(n)} :
Summing over all values of n, this estimate suggests that the total number of polydivisible numbers will be approximately
All numbers are represented in base b {\displaystyle b} , using A−Z to represent digit values 10 to 35.
The polydivisible numbers in base 5 are
The smallest base 5 polydivisible numbers with n digits are
The largest base 5 polydivisible numbers with n digits are
The number of base 5 polydivisible numbers with n digits are
The polydivisible numbers in base 10 are
The smallest base 10 polydivisible numbers with n digits are
The largest base 10 polydivisible numbers with n digits are
The number of base 10 polydivisible numbers with n digits are
The example below searches for polydivisible numbers in Python.
def find_polydivisible(base: int) -> list[int]: """Find polydivisible number.""" numbers = [] previous = [i for i in range(1, base)] new = [] digits = 2 while not previous == []: numbers.append(previous) for n in previous: for j in range(0, base): number = n * base + j if number % digits == 0: new.append(number) previous = new new = [] digits = digits + 1 return numbers
Polydivisible numbers represent a generalization of the following well-known[2] problem in recreational mathematics:
The solution to the problem is a nine-digit polydivisible number with the additional condition that it contains the digits 1 to 9 exactly once each. There are 2,492 nine-digit polydivisible numbers, but the only one that satisfies the additional condition is
Other problems involving polydivisible numbers include: