Harshad (Niven) Number Checker

Enter a positive integer to test the Harshad property and see the digit sum.

How it is calculated

The tool writes the number as text, adds its decimal digits, and tests whether the number divides by that sum with no remainder: n mod S = 0, where n is the number and S is its digit sum. If it does, the answer is Yes and the quotient n ÷ S is shown; if not, the answer is No and the quotient shows a dash. For example 19 has digit sum 10, and 19 does not divide by 10, so it fails. Only positive whole numbers up to 1015 are accepted. Zero, negative numbers, decimals such as 12.5, numbers above 1015 and input with a thousands separator give no result. The test is done in base 10; a number can be a Harshad number in one base and not in another. Plain integer arithmetic is used, so large inputs are exact.

Worked example

Test 2024. Digits: 2 + 0 + 2 + 4 = 8, so the digit sum is 8. Now divide: 2024 ÷ 8 = 253, a whole number with no remainder. The answer is Yes, the digit sum is 8 and the quotient is 253. So 2024 is a Harshad number. For comparison, 2023 has digit sum 7 and 2023 ÷ 7 = 289 exactly, so it passes as well, while 2022 has digit sum 6 and also divides (337).

Try this example →

Common mistakes

  • Dividing by the number of digits instead of their sum. For 2024 the divisor is 8 (the sum), not 4 (the count).
  • Entering a number with a decimal part, a minus sign or a thousands separator. Only plain positive whole numbers work, and the tool shows nothing for 12.5, −18 or 2,024.
  • Typing 0 as a trivial case. Zero is not accepted, because the digit sum would also be 0 and the division has no meaning.
  • Reading the quotient dash as an error. A dash simply means the number is not a Harshad number, so there is no whole quotient.
  • Assuming a number that fails here is a Harshad number in no number system. The check is in base 10 only.

About this calculator

A Harshad number — also called a Niven number — is a positive integer that is evenly divisible by the sum of its own digits. For example, 18 has digit sum 1+8=9, and 18÷9=2 with no remainder, so 18 qualifies. The name comes from Sanskrit, roughly ‘great joy,’ coined by the mathematician D. R. Kaprekar; ‘Niven number’ honors Ivan Niven, who wrote about the same property. Every number from 1 to 9 is trivially a Harshad number since a single digit always divides itself.

Harshad numbers are a staple of recreational number theory: they show up in puzzle collections, programming katas that ask you to test divisibility rules, and sequences studied on OEIS. Runs of consecutive Harshad numbers get rarer as numbers grow, which makes finding long unbroken chains an interesting computational challenge, and some coding exercises use Harshad-style digit-sum checks as a simple divisibility filter before more expensive primality or factoring tests.

Enter any positive integer and the calculator computes its digit sum and reports immediately whether it divides evenly, telling you whether the number has the Harshad property.

Was this helpful?

You can pick up to 3 reactions.

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators