Inmathematics, thedigit sum of anatural number in a givennumber base is the sum of all itsdigits. For example, the digit sum of thedecimal number would be
Let be a natural number. We define thedigit sum for base, to be the following:
where is one less than the number of digits in the number in base, and
is the value of each digit of the number.
For example, inbase 10, the digit sum of 84001 is
For any two bases and for sufficiently large natural numbers
The sum of the base 10 digits of theintegers 0, 1, 2, ... is given byOEIS: A007953 in theOn-Line Encyclopedia of Integer Sequences.Borwein & Borwein (1992) use thegenerating function of thisinteger sequence (and of the analogous sequence forbinary digit sums) to derive several rapidlyconvergingseries withrational andtranscendental sums.[2]
The digit sum can be extended to the negative integers by use of asigned-digit representation to represent each integer.
The amount of n-digit numbers with digit sum q can be calculated using:
The concept of a decimal digit sum is closely related to, but not the same as, thedigital root, which is the result of repeatedly applying the digit sum operation until the remaining value is only a single digit. The decimal digital root of any non-zero integer will be a number in the range 1 to 9, whereas the digit sum can take any value. Digit sums and digital roots can be used for quickdivisibility tests: a natural number isdivisible by 3 or 9if and only if its digit sum (or digital root) is divisible by 3 or 9, respectively. For divisibility by 9, this test is called therule of nines and is the basis of thecasting out nines technique for checking calculations.
Digit sums are also a common ingredient inchecksum algorithms to check the arithmetic operations of early computers.[3] Earlier, in an era of hand calculation,Edgeworth (1888) suggested using sums of 50 digits taken from mathematicaltables of logarithms as a form ofrandom number generation; if one assumes that each digit is random, then by thecentral limit theorem, these digit sums will have a random distribution closely approximating aGaussian distribution.[4]
The digit sum of thebinary representation of a number is known as itsHamming weight or population count; algorithms for performing this operation have been studied, and it has been included as a built-in operation in some computer architectures and someprogramming languages. These operations are used in computing applications includingcryptography,coding theory, andcomputer chess.
Harshad numbers are defined in terms of divisibility by their digit sums, andSmith numbers are defined by the equality of their digit sums with the digit sums of theirprime factorizations.