Harshad Number Calculator
Check whether an integer is divisible by the sum of its own decimal digits, with the quotient shown.
What it does
A Harshad number is an integer divisible by the sum of its decimal digits. The term comes from words meaning great joy in Sanskrit, and the same numbers are often called Niven numbers. Every one digit number qualifies, since the digit sum is the number itself.
The property depends on the base in which the number is written. This page uses ordinary base ten. Changing to another base would change which numbers pass the test, so the base is fixed here.
The check is short: add the digits, then divide the original number by that sum. If the remainder is zero the number is Harshad. This page reports the digit sum and, when the division succeeds, the exact quotient.
Harshad numbers appear in recreational number theory and in studies of digit based divisibility rules. Consecutive runs of them are possible, though long runs are rare.
The input limit is one trillion, which keeps digit sums small and the division exact. The tool returns a clear message for values outside the range.
How to use
- Enter a whole number n from 1 upward.
- Read the classification in the main result box.
- Check the digit sum beside it.
- If the test passes, read the quotient from n divided by the digit sum.
- The default n = 18 reproduces the worked example.
- Try n = 19 to see a number that fails the test.
Formula
- n
- The integer being tested.
- S(n)
- The sum of the decimal digits of n.
- n / S(n)
- The quotient, shown only when the remainder is zero.
The digit sum is computed by repeatedly taking the remainder modulo ten and dividing by ten. For a single digit number the sum equals the number, so the quotient is always one and the test always passes. The base ten convention is fixed.
Worked example
Example: n = 18
The page opens with n = 18.
- Write the digits: 1 and 8.
- Add them: 1 + 8 = 9.
- Divide 18 by 9, which gives 2 with no remainder.
- The tool reports digit sum 9, quotient 2, and Harshad number.
- For 19 the digit sum is 10 and 19 is not divisible by 10, so the test fails.
Reference table
| n | Digit sum | Quotient | Harshad |
|---|---|---|---|
| 7 | 7 | 1 | Yes |
| 10 | 1 | 10 | Yes |
| 12 | 3 | 4 | Yes |
| 18 | 9 | 2 | Yes |
| 19 | 10 | n/a | No |
| 20 | 2 | 10 | Yes |
Limits
- Only base ten digit sums are used.
- Inputs above one trillion are rejected.
- The quotient is shown as not available when the test fails.
- The tool gives a verdict, not a list of nearby Harshad numbers.
Common mistakes
- Adding digits more than once and using the digital root instead of the digit sum.
- Using the product of digits rather than the sum.
- Assuming every even number passes.
- Treating the quotient as the digit sum.
- Changing base without noticing that the answer changes.
Try it yourself
Quick checks. Answers sit tucked under each question.
Is 18 a Harshad number?
Yes. The digit sum is 9 and 18 divided by 9 is 2.
Is 19 a Harshad number?
No. The digit sum is 10 and 19 is not divisible by 10.
Is 20 a Harshad number?
Yes. The digit sum is 2 and 20 divided by 2 is 10.
Questions
What does Harshad mean?
It comes from Sanskrit words meaning great joy, describing a number divisible by its digit sum.
What is a Niven number?
Another name for the same property, after Ivan Niven.
Do single digit numbers qualify?
Yes, because a number divided by itself is one.
Does the base matter?
Yes. This page always uses base ten.
Are there consecutive Harshad numbers?
Yes, though long runs are uncommon.
What input range is accepted?
Whole numbers from 1 through 1,000,000,000,000.