Digit sum
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 would be
General Definition
[edit]Let be a natural number. We define the digit 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, in base 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 the integers 0, 1, 2, ... is given by OEIS: A007953 in the On-Line Encyclopedia of Integer Sequences. Borwein & Borwein (1992) 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]
Dhoria's Formula for Base 10
[edit]Let be a positive real number in base 10. We define the digit sum of number to the LEFT of the decimal point, where to be the following:
![Graph of 𝐺 ( 𝛼 ) for 0 < 𝛼 < 1000](http://upload.wikimedia.org/wikipedia/commons/thumb/7/72/GraphOfDigitSumFunction.png/512px-GraphOfDigitSumFunction.png)
Note that the notation of does not mean to do all calculations mod 10. It means to do all calculations regularly first, then take that result and get the remainder when dividing by 10. For example the digit sum of 123456789 is .
's domain is all positive real numbers but will ignore all digits to the right of the decimal point and only sum the digits to the left of the decimal point. So therefore.
It is important to note that this formula returns 0 for all powers of 10 and not the desired output of 1. So
Using quantifiers: where
This formula was developed by high school student Aryan Dhoria on January of 2025, in Massachusetts, USA.
Derivation of Dhoria's Formula
[edit]Observe what really means. will return the power needed to be raised on , to get the value of . For example returns which is how many powers of 10 we need to raise 10 by to get 324.
For real 's : . For real 's , : . For real 's , : . We can see a pattern emerging here with the logarithm of base 10. Notice that the range , is always a rational number that is between the number of digits of and 1 less then the number of digits than .
Since we know that this number will be always between the number of digits of and 1 less then the number of digits of , taking the ceiling of this value will always round it up to the biggest integer, which in our case is the number of digits of . Therefore,
will return the length (or number of digits) of x.
Now we have the length of , yet we still need the individual digits in order to calculate the digit sum. Observe what happens when taking any real , and dividing it by a power of . Say . . Dividing by a power of 10, (namely the 'th power of 10), moves the decimal point n places to the left. If you think about it, this also means moving the 'th digit from the right, to the ones place. Taking another example, . is in the ones place as it is the 'th digit (or 5'th digit) from the right. We still have those digits to the right of the decimal however. Rounding the number, by taking the ceiling: , will eliminate those digits to the right of the decimal point, but will also change the ones digit, which we just isolated, so instead lets take the floor. This will now remove the digits to the right of the decimal point and not change the ones place digit. Now we can successfully put any digit we want of a number, in the ones place. So now we have established that, will put the 'th digit from the right, to the ones place. However, putting the 'th digit from the right, to the ones place is ugly and rather to make it better, we should put the 'th digit in the ones place. We do this by simply raising to the length of the , minus . So instead of just , we use . So, will shift the 'th digit in the ones place. Using properties of exponents, we can write this alternatively as . Therefore,
will shift the 'th digit in the ones place
Now that we have found a way to place and isolate any digit we want of a number into the ones place, how do we extract that number itself? Rewording the question at hand actually helps quite a bit here. Our task is to get the ones digit of a number that we know has no other digits to the right of the decimal point, ( a natural number). Lets see if we can find a property about a number that does let us know what the ones digit of a number is, always. If we can find a predictable property like this, we then can use it to our advantage. The property we use here, is the divisibility rule for 10. A natural number is divisible by 10 if the ones digit is 0. The good thing about this, is that the converse is also true. If the ones digit is 0, of a natural number, than the number is divisible by 10. So now we have a property of a number that will tell us what the ones digit is (the digit of zero), with 100% certainty. Now using this fact, we can approach the problem a little differently now. Say for example, our number was 12345. Well is this number divisible by 10? Well lets find out: ( means not divisible). We see that the remainder, when dividing by 10, is the ones digit. Is our example just a coincidence or will this always happen? Well if 12345 were divisible by 10 then it would have to have its ones digit(5), be a 0. 12340 is a multiple of 10 and subtracting our original number with the closest multiple of 10 will give us the remainder. . So now we see that the remainder of a number divided by 10 can be calculated by taking the number and subtracting the smallest closest multiple of 10 to it. In general it would be:
Now we can see that dividing by will result in a remainder of which is just . Therefore taking the remainder of any number after dividing by will extract the ones digit. This is exactly what we need, but how do we get the remainder mathematically when dividing by a number? Well taking returns the remainder when is is divided by . Therefore to extract the 'th digit of a number, we can move the 'th digit to the ones place, and then take to get the ones digit. Therefore,
will return the 'th digit of
This formula has a domain of and not is because we have a logarithm, which cannot contain a negative argument. Now that we have an expression for the 'th digit of , we can just sum over all possible 's up to the length of which is . Writing this is formal notation only dictates that we change to be our summation variable . We now finally arrive at the following formula :
Sum of digits of
Extension to negative integers
[edit]The digit sum can be extended to the negative integers by use of a signed-digit representation to represent each integer.
Properties
[edit]The amount of n-digit numbers with digit sum q can be calculated using:
Applications
[edit]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
[edit]- Arithmetic dynamics
- Casting out nines
- Checksum
- Digital root
- Hamming weight
- Harshad number
- Perfect digital invariant
- Sideways sum
- Smith number
- Sum-product number
References
[edit]- ^ Bush, L. E. (1940), "An asymptotic formula for the average sum of the digits of integers", American Mathematical Monthly, 47 (3), Mathematical Association of America: 154–156, doi:10.2307/2304217, JSTOR 2304217.
- ^ Borwein, J. M.; Borwein, P. B. (1992), "Strange series and high precision fraud" (PDF), American Mathematical Monthly, 99 (7): 622–640, doi:10.2307/2324993, hdl:1959.13/1043650, JSTOR 2324993, archived from the original (PDF) on 2016-05-09, retrieved 2009-03-02.
- ^ Bloch, R. M.; Campbell, R. V. D.; Ellis, M. (1948), "The Logical Design of the Raytheon Computer", Mathematical Tables and Other Aids to Computation, 3 (24), American Mathematical Society: 286–295, doi:10.2307/2002859, JSTOR 2002859.
- ^ Edgeworth, F. Y. (1888), "The Mathematical Theory of Banking" (PDF), Journal of the Royal Statistical Society, 51 (1): 113–127, archived from the original (PDF) on 2006-09-13.
External links
[edit]