gives the number of d digits in the base-b representation of n.
- Integer mathematical function, suitable for both symbolic and numerical manipulation.
- DigitCount[n] is equivalent to DigitCount[n,10,Mod[Range,10]].
Examplesopen allclose all
Basic Examples (3)
Number of 1s in binary representation:
Number of 1s and 0s:
Number of each digit 1, 2, 3, ..., 0 in 100!:
Plot the number of 1s in the base-2 representation:
Count the number of digits 1 and 2 in ternary representation:
Thue–Morse sequence [more info]:
Number of black cells at step t in the rule 90 cellular automaton (binomial coefficients mod 2):