DigitCount

DigitCount[n,b,d]

gives the number of d digits in the base-b representation 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 allclose all

Basic Examples  (3)

Binary representation:

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:

Scope  (1)

Count the number of digits 1 and 2 in ternary representation:

Applications  (2)

ThueMorse sequence [more info]:

Number of black cells at step t in the rule 90 cellular automaton (binomial coefficients mod 2):

Wolfram Research (1999), DigitCount, Wolfram Language function, https://reference.wolfram.com/language/ref/DigitCount.html.

Text

Wolfram Research (1999), DigitCount, Wolfram Language function, https://reference.wolfram.com/language/ref/DigitCount.html.

CMS

Wolfram Language. 1999. "DigitCount." Wolfram Language & System Documentation Center. Wolfram Research. 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_2023_digitcount, author="Wolfram Research", title="{DigitCount}", year="1999", howpublished="\url{https://reference.wolfram.com/language/ref/DigitCount.html}", note=[Accessed: 18-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_digitcount, organization={Wolfram Research}, title={DigitCount}, year={1999}, url={https://reference.wolfram.com/language/ref/DigitCount.html}, note=[Accessed: 18-March-2024 ]}