DigitCount[n,b,d]
gives the number of d digits in the base-b representation of n.
DigitCount[n,b,d,len]
gives the number of d digits in the base-b representation of the last len digits of n.
DigitCount[n,b]
gives a list of the numbers of ,
, …,
,
digits in the base-b representation of n.
DigitCount[n]
gives a list of the numbers of ,
, …,
,
digits in the base-10 representation of n.


DigitCount

DigitCount[n,b,d]
gives the number of d digits in the base-b representation of n.
DigitCount[n,b,d,len]
gives the number of d digits in the base-b representation of the last len digits of n.
DigitCount[n,b]
gives a list of the numbers of ,
, …,
,
digits in the base-b representation of n.
DigitCount[n]
gives a list of the numbers of ,
, …,
,
digits in the base-10 representation of n.
Details

- Integer mathematical function, suitable for both symbolic and numerical manipulation.
- DigitCount[n] is equivalent to DigitCount[n,10,Mod[Range[10],10]].
Examples
open all close allBasic Examples (3)
Scope (2)
Count the number of each of the decimal digits in a number:
Do the same thing, explicitly specifying the base:
Count just the number of zeros:
Count the number of zeros, assuming a 9-digit number:
Count the number of digits 1 and 2 in ternary representation:
Count the number of digits 1 and 2 in the last 12 digits of the ternary representation:
Applications (2)
Thue–Morse sequence [more info]:
Number of black cells at step t in the rule 90 cellular automaton (binomial coefficients mod 2):
Properties & Relations (2)
DigitCount[n,b,d] is effectively Count[IntegerDigits[n,b],d]:
DigitCount[n,b,d,len] is effectively Count[PadLeft[IntegerDigits[n,b],len],d]:
See Also
IntegerLength IntegerDigits DigitSum FromDigits BitAnd IntegerExponent HammingDistance ThueMorse
Function Repository: DigitSum
Tech Notes
Related Guides
Related Links
History
Introduced in 1999 (4.0) | Updated in 2025 (14.2)
Text
Wolfram Research (1999), DigitCount, Wolfram Language function, https://reference.wolfram.com/language/ref/DigitCount.html (updated 2025).
CMS
Wolfram Language. 1999. "DigitCount." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/DigitCount.html.
APA
Wolfram Language. (1999). DigitCount. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DigitCount.html
BibTeX
@misc{reference.wolfram_2025_digitcount, author="Wolfram Research", title="{DigitCount}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/DigitCount.html}", note=[Accessed: 15-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_digitcount, organization={Wolfram Research}, title={DigitCount}, year={2025}, url={https://reference.wolfram.com/language/ref/DigitCount.html}, note=[Accessed: 15-August-2025]}