DigitCount
Counts of each digit (1 through 9, then 0) occurring in n, base 10 by default.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram Language
DigitCount✓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.DigitCount(n, base, digit(s), width)counted over exactly width digits, padded or truncated to fit.Typed signatures
| Type | Package | Applies |
|---|---|---|
(integer, integer?, integer?) -> integer | list<integer> | compute-engine | always |
(integer, integer?, (integer | list<integer>)?, integer?) -> integer | list<integer> | numeralsreplaces compute-engine | always |
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
Scope #
Properties #
Result lists counts for digits then ; zero is a single
live ↗InOut
Known value · Wolfram MathematicalFunctionData, DigitCount
Zero in base 3, counted under the final slot for digit
live ↗InOut
Known value · Wolfram MathematicalFunctionData, DigitCount
A lone digit 2 shows in the middle slot
live ↗InOut
Known value · Wolfram MathematicalFunctionData, DigitCount
: one of digit 1, one of digit 2
live ↗InOut
Known value · Wolfram MathematicalFunctionData, DigitCount
Possible issues #
About
| Examples | 33 |
|---|---|
| Checked against | Wolfram Language 33 agree |
| Crosswalk | Wolfram Language |
See also: IntegerDigits, DigitSum