PRODUCTS
Products Overview
Mathematica
Mathematica Student Edition
Mathematica Home Edition
Wolfram
CDF Player
(free download)
Computable Document Format (CDF)
web
Mathematica
grid
Mathematica
Wolfram
Workbench
Wolfram
SystemModeler
Wolfram
Finance Platform
Mathematica
Add-Ons
Wolfram|Alpha Products
SOLUTIONS
Solutions Overview
Engineering
Aerospace Engineering & Defense
Chemical Engineering
Control Systems
Electrical Engineering
Image Processing
Industrial Engineering
Materials Science
Mechanical Engineering
Operations Research
Optics
Petroleum Engineering
Biotechnology & Medicine
Bioinformatics
Medical Imaging
Finance, Statistics & Business Analysis
Actuarial Sciences
Data Analysis & Mining
Econometrics
Economics
Financial Engineering & Mathematics
Financial Risk Management
Statistics
Software Engineering & Content Delivery
Authoring & Publishing
Interface Development
Software Engineering
Web Development
Science
Astronomy
Biological Sciences
Chemistry
Environmental Sciences
Geosciences
Social & Behavioral Sciences
Design, Arts & Entertainment
Game Design, Special Effects & Generative Art
Education
STEM Education Initiative
Higher Education
Community & Technical College Education
Primary & Secondary Education
Students
Technology
Computable Document Format (CDF)
High-Performance & Parallel Computing (HPC)
See Also: Technology Guide
PURCHASE
Online Store
Other Ways to Buy
Volume & Site Licensing
Contact Sales
Software
Service
Upgrades
Training
Books
Merchandise
SUPPORT
Support Overview
Mathematica
Documentation
Knowledge Base
Learning Center
Technical Services
Community & Forums
Training
Does My Site Have a License?
Wolfram User Portal
COMPANY
About Wolfram Research
News
Events
Wolfram Blog
Partnerships
Employment Opportunities
History of
Mathematica
Stephen Wolfram's Home Page
Contact Us
OUR SITES
All Sites
Wolfram|Alpha
Demonstrations Project
MathWorld
Integrator
Wolfram Functions Site
Mathematica Journal
Wolfram Media
Wolfram
Tones
Wolfram Science
Stephen Wolfram
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE
DOCUMENTATION CENTER
FOR THE LATEST INFORMATION.
DOCUMENTATION CENTER SEARCH
New to
Mathematica
?
Find your learning path
»
Mathematica
>
Mathematics and Algorithms
>
Mathematical Functions
>
Number Theoretic Functions
>
Number Digits
>
DigitCount
>
BUILT-IN MATHEMATICA SYMBOL
Integer and Number Theoretic Functions
Tutorials »
|
IntegerLength
IntegerDigits
FromDigits
BitAnd
IntegerExponent
HammingDistance
See Also »
|
Integer Functions
Mathematical Functions
Number Digits
Number Theoretic Functions
Number Theory
Representation of Numbers
More About »
DigitCount
DigitCount
gives the number of
d
digits in the base-
b
representation of
n
.
DigitCount
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
.
MORE INFORMATION
Integer mathematical function, suitable for both symbolic and numerical manipulation.
DigitCount
[
n
]
is equivalent to
DigitCount
[
n
, 10,
Mod
[
Range
[10], 10]]
.
EXAMPLES
CLOSE 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:
Binary representation:
In[1]:=
Out[1]=
Number of 1s in binary representation:
In[2]:=
Out[2]=
Number of 1s and 0s:
In[3]:=
Out[3]=
Number of each digit 1, 2, 3, ..., 0 in 100!:
In[1]:=
Out[1]=
Plot the number of 1s in the base-2 representation:
In[1]:=
Out[1]=
Scope
(1)
Count the number of digits 1 and 2 in ternary representation:
Applications
(2)
Thue-Morse sequence
Number of black cells at step
t
in the rule 90 cellular automaton (binomial coefficients mod 2):
SEE ALSO
IntegerLength
IntegerDigits
FromDigits
BitAnd
IntegerExponent
HammingDistance
TUTORIALS
Integer and Number Theoretic Functions
MORE ABOUT
Integer Functions
Mathematical Functions
Number Digits
Number Theoretic Functions
Number Theory
Representation of Numbers
RELATED LINKS
MathWorld
The Wolfram Functions Site
NKS|Online
(
A New Kind of Science
)
New in 4