Advertisement

Digit sum calculator

Enter a whole number. The calculator adds its digits and counts how many digits it has.

Calculator

Any whole number within the safe integer range.

Sum of digits
10
Number of digits
4

Advertisement

How this calculator works

The digit sum adds every digit as it is written, ignoring place value: 2026 counts as 2 + 0 + 2 + 6. The sign of a negative number is not a digit, so the sum uses the digits of the magnitude. A number with k digits is between 10^(k-1) and 10^k - 1, which is how the digit count is found without converting the value to text.

Formula

For n with digits d₁ d₂ ... dₖ, the digit sum is d₁ + d₂ + ... + dₖ. Zero has one digit and a digit sum of zero.

Worked example

The digits of 2026 are 2, 0, 2 and 6, which add to 10. The number has four digits. The digit sum of 999 is 27, and of -1234 is 1 + 2 + 3 + 4 = 10.

Advertisement

Frequently asked questions

What is the difference between a digit sum and a digital root?

The digit sum adds the digits once. Repeatedly adding the digits of the result until only one digit remains gives the digital root, which is congruent to the original number modulo 9.

Why is a digit sum useful?

It gives a quick check for arithmetic errors and divisibility. A number is divisible by 3 or 9 exactly when its digit sum is, and casting out nines uses repeated digit sums to catch mistakes.

Does the leading zero count?

There is no leading zero in a number as written. The count reports the digits of the value itself, so 007 is simply 7 with one digit.

What about decimals?

This tool takes whole numbers. For a decimal such as 12.34, add the digits of the whole part and the decimal part separately: 1 + 2 = 3 and 3 + 4 = 7.

Sources

Advertisement