Digit sum

From HandWiki
Revision as of 14:30, 6 February 2024 by AstroAI (talk | contribs) (simplify)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Sum of a number's digits

In mathematics, the digit sum of a natural number in a given number base is the sum of all its digits. For example, the digit sum of the decimal number [math]\displaystyle{ 9045 }[/math] would be [math]\displaystyle{ 9 + 0 + 4 + 5 = 18. }[/math]

Definition

Let [math]\displaystyle{ n }[/math] be a natural number. We define the digit sum for base [math]\displaystyle{ b \gt 1 }[/math], [math]\displaystyle{ F_b : \mathbb{N} \rightarrow \mathbb{N} }[/math] to be the following:

[math]\displaystyle{ F_b(n) = \sum_{i=0}^{k} d_i }[/math]

where [math]\displaystyle{ k = \lfloor \log_{b}{n} \rfloor }[/math] is one less than the number of digits in the number in base [math]\displaystyle{ b }[/math], and

[math]\displaystyle{ d_i = \frac{n \bmod{b^{i+1}} - n \bmod b^i}{b^i} }[/math]

is the value of each digit of the number.

For example, in base 10, the digit sum of 84001 is [math]\displaystyle{ F_{10}(84001) = 8 + 4 + 0 + 0 + 1 = 13. }[/math]

For any two bases [math]\displaystyle{ 2 \leq b_1 \lt b_2 }[/math] and for sufficiently large natural numbers [math]\displaystyle{ n, }[/math]

[math]\displaystyle{ \sum_{k=0}^n F_{b_1}(k) \lt \sum_{k=0}^n F_{b_2}(k). }[/math][1]

The sum of the base 10 digits of the integers 0, 1, 2, ... is given by OEISA007953 in the On-Line Encyclopedia of Integer Sequences. (Borwein Borwein) use the generating function of this integer sequence (and of the analogous sequence for binary digit sums) to derive several rapidly converging series with rational and transcendental sums.[2]

Extension to negative integers

The digit sum can be extended to the negative integers by use of a signed-digit representation to represent each integer.

Applications

The concept of a decimal digit sum is closely related to, but not the same as, the digital 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 quick divisibility tests: a natural number is divisible by 3 or 9 if and only if its digit sum (or digital root) is divisible by 3 or 9, respectively. For divisibility by 9, this test is called the rule of nines and is the basis of the casting out nines technique for checking calculations.

Digit sums are also a common ingredient in checksum 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 mathematical tables of logarithms as a form of random number generation; if one assumes that each digit is random, then by the central limit theorem, these digit sums will have a random distribution closely approximating a Gaussian distribution.[4]

The digit sum of the binary representation of a number is known as its Hamming 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 some programming languages. These operations are used in computing applications including cryptography, coding theory, and computer chess.

Harshad numbers are defined in terms of divisibility by their digit sums, and Smith numbers are defined by the equality of their digit sums with the digit sums of their prime factorizations.

See also

References

  1. Bush, L. E. (1940), "An asymptotic formula for the average sum of the digits of integers", American Mathematical Monthly (Mathematical Association of America) 47 (3): 154–156, doi:10.2307/2304217 .
  2. Borwein, J. M.; Borwein, P. B. (1992), "Strange series and high precision fraud", American Mathematical Monthly 99 (7): 622–640, doi:10.2307/2324993, http://www.cecm.sfu.ca/personal/pborwein/PAPERS/P56.pdf, retrieved 2009-03-02 .
  3. Bloch, R. M.; Campbell, R. V. D.; Ellis, M. (1948), "The Logical Design of the Raytheon Computer", Mathematical Tables and Other Aids to Computation (American Mathematical Society) 3 (24): 286–295, doi:10.2307/2002859 .
  4. Edgeworth, F. Y. (1888), "The Mathematical Theory of Banking", Journal of the Royal Statistical Society 51 (1): 113–127, http://instruct1.cit.cornell.edu/courses/econ719/Edgeworth.pdf .

External links