Count Digits Calculator

Enter a whole number to count its digits, digit sum and distinct digits.

How it is calculated

The input is read as text and must be a whole number: an optional minus sign followed by digits only. The tool removes the sign and any leading zeros, then looks at each remaining digit in turn.

digit count = number of digits left
digit sum = d₁ + d₂ + … + dₙ
distinct digits = how many of 0–9 appear at least once

Because it works on the text, numbers far beyond the normal integer range are fine; a 54-digit number is counted correctly. Leading zeros are not counted, so 007 is treated as 7 and gives 1 digit with digit sum 7, and the sign is ignored, so -905 and 905 give the same result. Zero, or 000, counts as 1 digit. A decimal point, comma, space or plus sign makes the input invalid and no result is shown.

Worked example

Take 1223334444. Count the digits: 10. Add them: 1 + 2 + 2 + 3 + 3 + 3 + 4 + 4 + 4 + 4 = 30, so the digit sum is 30. The digits that occur are 1, 2, 3 and 4, so there are 4 distinct digits. The result is 10 digits, digit sum 30 and 4 distinct digits. Since 30 is divisible by 3 but not by 9, the number itself is divisible by 3 and not by 9.

Try this example →

Common mistakes

  • Typing a thousands separator (1,000 or 1 000). The tool accepts digits only and shows no result, so remove the separators first.
  • Entering a decimal such as 3.14 and expecting the digits after the point to count. Decimals are rejected; enter the digits without the point if you want them counted.
  • Expecting leading zeros to count. 007 reports 1 digit, because the number is 7; if you need the length of a code such as 007, count its characters yourself.
  • Confusing the digit sum with the digital root. The tool gives the sum in one step (1223334444 gives 30), not the repeated sum that ends in a single digit (30 → 3).
  • Treating the minus sign as a digit. It is ignored, so -905 reports 3 digits, not 4.

About this calculator

Counting digits sounds trivial but the concept underpins several useful checks: the digit count of a whole number tells you its order of magnitude, the digit sum (adding every individual digit together) is the basis of classic divisibility tests such as “a number is divisible by 3 or 9 if its digit sum is too,” and the count of distinct digits shows how much repetition or variety the number's digits contain.

These properties show up in recreational number theory (digit sums are the building block behind Harshad numbers, digital roots and checksum algorithms like the one used to validate ISBNs and credit card numbers), in programming exercises that practise breaking a number into digits, and in everyday checks like verifying how many digits an ID, account or phone number should have.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators