A digit is a symbol used to represent a number in a given base. Decimal digits are the ten symbols 0 through 9 used in the decimal numeral system, while binary digits are the two symbols 0 and 1 used in binary. Their positions determine place values in a decimal expansion or binary expansion, respectively.
The number of digits
in an integer
is the number of symbols in that base
(usually 10) required to represent it. The numbers 1 to
9 are therefore single digits, while the numbers 10 to
99 are double digits. For a nonzero integer
and an integer base
,
the number of base-
digits can be calculated as
|
(1)
|
where is the floor
function. The number 0 is represented by one digit.
For
, the formula becomes
|
(2)
|
The number of occurrences of the digit in the number
represented in base
is given by the Wolfram
Language function DigitCount[n,
b, d], with DigitCount[n,
b] giving a list of the numbers of each digit in
. The total number of digits in a nonzero integer is given by IntegerLength[n,
b]. The function IntegerLength[0]
returns 0, although the representation of 0 has one digit.
For any fixed integer base and any specified digit
with
,
almost all positive
integers contain
in their base-
representation. There are
positive integers with
digits, of which at most
omit
. If
has
digits, then
, and at most
of the first
positive integers omit
. Their proportion is therefore at most
, which tends to 0 as
. The decimal
digit 3 is an illustrative case (Numberphile 2012).
The positive integers with distinct base-10 digits are given by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
23, ... (OEIS A010784). The number of -digit positive
integers with distinct digits is given, for
, by
|
(3)
| |||
|
(4)
| |||
|
(5)
| |||
|
(6)
|
where is a Pochhammer
symbol. For
,
2, ..., the first few values are 9, 81, 648, 4536, 27216, 136080, 544320, 1632960,
3265920, and 3265920 (OEIS A073531). There
are therefore exactly
|
(7)
| |||
|
(8)
|
such numbers (Pondiczery 1975-a pseudonym for Ralph P. Boas; Foregger 1976), the largest of which is 9876543210.
The sum of the reciprocals of these 8877690 integers (Pondiczery 1975, Foregger 1976) is a rational number with numerator having 14816583 digits and denominator having 14816582 digits and given by
|
(9)
| |||
|
(10)
|
(OEIS A117914), computed by E. W. Weisstein on Apr. 1, 2006 using gridMathematica.
Numbers in base-10 which are divisible by their digits are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22, 24, 33, 36, 44, 48, 55, 66, 77, 88, 99, 111, 112, 115, 122, ... (OEIS A034838). Numbers which are divisible by the sum of their digits are called Harshad numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, ... (OEIS A005349). Numbers which are divisible by both their digits and the sum of their digits are 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, 111, 112, 126, 132, 135, 144, ... (OEIS A051004). The positive integers equal to the product of their decimal digits multiplied by the sum of those digits are called sum-product numbers. They are exactly 1, 135, and 144. The sequence OEIS A038369 also includes 0, which satisfies the same digit equation.
| order | OEIS | Numbers ( | |
| 2 | increasing | ||
| 2 | nondecreasing | A000225 | 3, 7, 15, 31, 63, 127, 255, 511, 1023, ... |
| 2 | nonincreasing | A023758 | 2, 3, 4, 6, 7, 8, 12, 14, 15, 16, 24, 28, 30, 31, ... |
| 2 | decreasing | 2 | |
| 10 | increasing | A009993 | 12, 13, 14, 15, 16, 17, 18, 19, 23, 24, 25, 26, ... |
| 10 | nondecreasing | A009994 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, ... |
| 10 | nonincreasing | A009996 | 10, 11, 20, 21, 22, 30, 31, 32, 33, 40, 41, 42, ... |
| 10 | decreasing | A009995 | 10, 20, 21, 30, 31, 32, 40, 41, 42, 43, 50, 51, ... |
| 16 | increasing | A023784 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, ... |
| 16 | nondecreasing | A023757 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, ... |
| 16 | nonincreasing | A023771 | 16, 17, 32, 33, 34, 48, 49, 50, 51, 64, 65, 66, ... |
| 16 | decreasing | A023797 | 16, 32, 33, 48, 49, 50, 64, 65, 66, 67, 80, 81, ... |
In hexadecimal, numbers with increasing digits are called metadromes, those with nondecreasing digits are called plaindromes, those with nonincreasing digits are called nialpdromes, and those with decreasing digits are called katadromes.
Counting 0 as a one-digit number, the count of nonnegative integers with strictly increasing digits in base is
, and the number with strictly decreasing digits is
.