The -ary digit count
is the number of occurrences of the digit
in the base-
representation of a positive
integer
, where
and
are integers. The digit
count is implemented in the Wolfram Language
as DigitCount[n,
b, d].
The number of 1s
in the binary representation of a positive
integer
, illustrated above, is given by
|
(1)
| |||
|
(2)
|
where
is the greatest dividing exponent of
2 with respect to
. This is a special application
of the general result that the greatest
dividing exponent of a prime
with respect to
is
(Vardi 1991, Graham et al. 1994). Writing
for
, the number of 1s is also
given, for
, by the recurrence
relation
|
(3)
| |||
|
(4)
|
with , and by
|
(5)
|
where
is the denominator of
|
(6)
|
For , 2, ..., the first few values are 1, 1, 2, 1, 2,
2, 3, 1, 2, 2, 3, ... (OEIS A000120; Smith
1966, Graham 1970, McIlroy 1974).
For a binary number, the count of 1s is equal to the digit sum
. The quantity
is called the parity
of a nonnegative integer
.
Writing
for the number of 0s in the binary representation of
without leading zeros,
and
satisfy the identities
|
(7)
| |||
|
(8)
|
where
is the Euler-Mascheroni constant and
(OEIS A094640)
is its "alternating analog" (Sondow 2005).
Let and
be the numbers of even and
odd decimal digits,
respectively, of
. Then
|
(9)
| |||
|
(10)
| |||
|
(11)
|
where the latter (OEIS A096614) is transcendental (Borwein et al. 2004, pp. 14-15).