({{, (RefLink[IntegerDigits, paclet:ref/IntegerDigits])[n]
gives a list of the decimal digits in the integer n. }, {, (RefLink[IntegerDigits, paclet:ref/IntegerDigits])[n,b]
gives a list of the base b digits in the integer n. }, {, (RefLink[IntegerDigits, paclet:ref/IntegerDigits])[n,b,len]
pads the list on the left with zeros to give a list of length len. }, {, (RefLink[IntegerDigits, paclet:ref/IntegerDigits])[n,(RefLink[MixedRadix, paclet:ref/MixedRadix])[blist]]
uses the mixed radix with list of bases blist.}})

OpenersNotesSection(Spacer1)Details

(RefLink[IntegerDigits, paclet:ref/IntegerDigits]) gives the most significant digit first, as in standard positional notation.

(RefLink[IntegerDigits, paclet:ref/IntegerDigits])[n] discards the sign of n.

If len is less than the number of digits in n, then the len least significant digits are returned.

(RefLink[IntegerDigits, paclet:ref/IntegerDigits])[0] gives {0}.

(RefLink[FromDigits, paclet:ref/FromDigits]) can be used as the inverse of (RefLink[IntegerDigits, paclet:ref/IntegerDigits]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (20)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Find digits in base 10:

IntegerDigits[58127]

Find digits in base 2:

IntegerDigits[58127,2]

Find digits in a mixed radix system:

IntegerDigits[102341,MixedRadix[{24,60,60}]]

OpenersExampleSection1(Spacer1)Scope  (8)

Bases larger than 10 can be used:

IntegerDigits[58127,16]

(RefLink[IntegerDigits, paclet:ref/IntegerDigits]) threads itself over elements of lists:

IntegerDigits[{6,7,2},2]

Find the digits of 7 in different bases:

IntegerDigits[7,{2,3,4}]

By default, (RefLink[IntegerDigits, paclet:ref/IntegerDigits]) includes no leading zeros:

IntegerDigits[Range[0,7],2]

Pad all digit lists to be length 3:

IntegerDigits[Range[0,7],2,3]

Find only the last 4 digits:

IntegerDigits[6345354,10,4]

Find digits using a (RefLink[MixedRadix, paclet:ref/MixedRadix]) specification:

IntegerDigits[137,MixedRadix[{3,12}]]

Find only the last 2 digits:

IntegerDigits[1084,MixedRadix[{17,15,11}],2]

OpenersExampleSection2(Spacer1)Applications  (4)

Leading digits of factorials:

Table[First[IntegerDigits[n!]],{n,50}]

(RefLink[ChampernowneNumber, paclet:ref/ChampernowneNumber]) has a decimal expansion that is a concatenation of consecutive integers:

Join@@Table[IntegerDigits[i],{i,30}]

Compare to (RefLink[ChampernowneNumber, paclet:ref/ChampernowneNumber]):

N[ChampernowneNumber[10],Length[%]]

Cantor set construction:

Table[If[FreeQ[IntegerDigits[n-1,3],1],1,0],{n,27}]

Construct a van der Corput sequence:

vanderCorput[b_,n_]:=FromDigits[IntegerDigits[n,b],1/b]/b

The sequence forms a dense set that is equidistributed in the unit interval:

QuantilePlot[Table[vanderCorput[2,n],{n,50}],UniformDistribution[]]

Build a Halton sequence:

Halton[n_]:={vanderCorput[2,n],vanderCorput[3,n]}

Illustrate low-discrepancy property of the sequence:

Table[Circle[Halton[n],0.01],{n,256}]//Graphics

OpenersExampleSection3(Spacer1)Properties & Relations  (4)

Find all combinations of 3 binary digits:

Table[IntegerDigits[i,2,3],{i,0,7}]

Tuples[{0,1},3]

Pad digit lists to be the same length:

PadLeft[Table[IntegerDigits[i^2,2],{i,5}]]

The sign is ignored:

IntegerDigits[-3134]

Express an amount of seconds in hours, minutes, and seconds:

IntegerDigits[98534,MixedRadix[{24,60,60}]]

It can also be obtained with (RefLink[NumberDecompose, paclet:ref/NumberDecompose]):

NumberDecompose[98534,{86400,3600,60,1}]

Perform the same computation using (RefLink[Quantity, paclet:ref/Quantity]) objects:

UnitConvert[Quantity[98534,"Seconds"],MixedUnit[{"Days","Hours","Minutes","Seconds"}]]

OpenersExampleSection4(Spacer1)Neat Examples  (1)

Leading digits of factorials in base 100:

ListLinePlot[Table[First[IntegerDigits[n!,100]],{n,300}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[FromDigits, paclet:ref/FromDigits])  ▪  (RefLink[IntegerString, paclet:ref/IntegerString])  ▪  (RefLink[NumberExpand, paclet:ref/NumberExpand])  ▪  (RefLink[DigitCount, paclet:ref/DigitCount])  ▪  (RefLink[IntegerLength, paclet:ref/IntegerLength])  ▪  (RefLink[NumberDecompose, paclet:ref/NumberDecompose])  ▪  (RefLink[RealDigits, paclet:ref/RealDigits])  ▪  (RefLink[BaseForm, paclet:ref/BaseForm])  ▪  (RefLink[NumberForm, paclet:ref/NumberForm])  ▪  (RefLink[RomanNumeral, paclet:ref/RomanNumeral])  ▪  (RefLink[IntegerReverse, paclet:ref/IntegerReverse])  ▪  (RefLink[PalindromeQ, paclet:ref/PalindromeQ])  ▪  (RefLink[IntegerExponent, paclet:ref/IntegerExponent])  ▪  (RefLink[IntegerPart, paclet:ref/IntegerPart])  ▪  (RefLink[ContinuedFraction, paclet:ref/ContinuedFraction])  ▪  (RefLink[Tuples, paclet:ref/Tuples])  ▪  (RefLink[BitAnd, paclet:ref/BitAnd])  ▪  (RefLink[BitOr, paclet:ref/BitOr])  ▪  (RefLink[BitLength, paclet:ref/BitLength])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Digits in Numbers, paclet:tutorial/DigitsInNumbers])}, {▪(RefLinkPlain[Integer and Number Theoretic Functions, paclet:tutorial/IntegerAndNumberTheoreticalFunctions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Constructing Lists, paclet:guide/ConstructingLists])}, {▪(RefLinkPlain[Number Digits, paclet:guide/NumberDigits])}, {▪(RefLinkPlain[Representation of Numbers, paclet:guide/RepresentationOfNumbers])}, {▪(RefLinkPlain[Numerical Evaluation & Precision, paclet:guide/NumericalEvaluationAndPrecision])}, {▪(RefLinkPlain[Discrete Mathematics, paclet:guide/DiscreteMathematics])}, {▪(RefLinkPlain[Number Theoretic Functions, paclet:guide/NumberTheoreticFunctions])}, {▪(RefLinkPlain[Additive Number Theory, paclet:guide/AdditiveNumberTheory])}, {▪(RefLinkPlain[Number Theory, paclet:guide/NumberTheory])}, {▪(RefLinkPlain[Integer Functions, paclet:guide/IntegerFunctions])}, {▪(RefLinkPlain[Mathematical Functions, paclet:guide/MathematicalFunctions])}, {▪(RefLinkPlain[Atomic Elements of Expressions, paclet:guide/AtomicElementsOfExpressions])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(Spacer1)▪(RefLinkPlain[(Spacer1)Implementation notes: Numerical and Related Functions, paclet:tutorial/SomeNotesOnInternalImplementation#23292])}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/23-more-about-numbers.html])(WebLink[: More about Numbers, https://www.wolfram.com/language/elementary-introduction/23-more-about-numbers.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/05-operations-on-lists.html])(WebLink[: Operations on Lists, https://www.wolfram.com/language/elementary-introduction/05-operations-on-lists.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/26-pure-anonymous-functions.html])(WebLink[: Pure Anonymous Functions, https://www.wolfram.com/language/elementary-introduction/26-pure-anonymous-functions.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/46-writing-good-code.html])(WebLink[: Writing Good Code, https://www.wolfram.com/language/elementary-introduction/46-writing-good-code.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NKS.png(Spacer1)NKS|Online, http://www.wolframscience.com/nksonline/index/search.cgi?SearchIndex=IntegerDigits]) ((WebLink[A New Kind of Science, http://www.wolframscience.com/nksonline/]))}})}})