DigitCount
Usage
• DigitCount[n, b, d]用来给出n的b进制表示中数字d的个数.
• DigitCount[n, b]用来给出n的b进制表示中数字1,2,...,b-1, 0的个数.
• DigitCount[n]用来给出n的10进制表示中数字1,2,...,9, 0的个数.
Notes
• DigitCount[n]等价于 DigitCount[n, 10, Mod[Range[10],10]].
Further Examples
Here is a small number.
In[1]:=
|
Here are two ways to see its digits in base .
In[2]:=
|
Out[2]//BaseForm=
|
In[3]:=
|
Out[3]=
|
This counts how many times occurs in the base expansion of x.
In[4]:=
|
Out[4]=
|
In the list of digits there are ones, two, threes, fours, fives, sixes and zeros.
In[5]:=
|
Out[5]=
|
|