Skip to content

DigitCount

Counts of each digit (1 through 9, then 0) occurring in n, base 10 by default.

Wolfram LanguageDigitCount
DigitCount(n)counts of each digit 1-9 then 0, base 10.
DigitCount(n, base)counts of each digit in the given base, highest digit value first.
DigitCount(n, base, digit)count of just one digit value.

Domain: Number theory

Details
  • Equivalent to tallying IntegerDigits(n, base) bucket by bucket.
  • The default base-10 form orders counts 1 through 9, then 0 last.
  • The 3-argument form isolates the count of a single digit value.
  • Trailing zeros count individually -- 122000 has three trailing 0 digits, not a single "trailing zeros" tally.

Examples

See also: IntegerDigits, DigitSum