Tool to calculate, verify, test and identify Harshad numbers (Niven numbers), understand their definition, their mathematical properties and calculate them automatically.
Harshad Number - dCode
Tag(s) : Arithmetics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
A Harshad (or Niven) number is a natural number divisible by the sum of its own digits.
The term Harshad comes from Sanskrit and means that which brings joy.
Take a number $ N $ and calculate the sum of all its digits.
Then check if the division of the number by this sum is an integer (i.e., the remainder is zero).
If so, the number $ N $ is a Harshad number.
Example: The number $ 18 $ has the sum of its digits: $ 1 + 8 = 9 $, and when performing the division $ 18 / 9 = 2 $, the remainder is $ 0 $. Therefore, $ 18 $ is a Harshad number because it is divisible by $ 9 $ (the sum of its digits).
The list of Harshad numbers up to 1000 is: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90, 100, 102, 108, 110, 111, 112, 114, 117, 120, 126, 132, 133, 135, 140, 144, 150, 152, 153, 156, 162, 171, 180, 190, 192, 195, 198, 200, 201, 204, 207, 209, 210, 216, 220, 222, 224, 225, 228, 230, 234, 240, 243, 247, 252, 261, 264, 266, 270, 280, 285, 288, 300, 306, 308, 312, 315, 320, 322, 324, 330, 333, 336, 342, 351, 360, 364, 370, 372, 375, 378, 392, 396, 399, 400, 402, 405, 407, 408, 410, 414, 420, 423, 432, 440, 441, 444, 448, 450, 460, 465, 468, 476, 480, 481, 486, 500, 504, 506, 510, 511, 512, 513, 516, 518, 522, 531, 540, 550, 552, 555, 558, 576, 588, 592, 594, 600, 603, 605, 612, 621, 624, 629, 630, 640, 644, 645, 648, 660, 666, 684, 690, 700, 702, 704, 711, 715, 720, 730, 732, 735, 736, 738, 756, 770, 774, 777, 780, 782, 792, 800, 801, 803, 804, 810, 820, 825, 828, 832, 840, 846, 864, 870, 874, 880, 882, 888, 900, 902, 910, 912, 915, 918, 935, 936, 954, 960, 966, 972, 990, 999, 1000
See the sequence OEIS A005349 here
Yes. It has been shown that there are infinitely many Harshad numbers.
A Harshad prime number must have a divisor that is either 1 or itself as the sum of its digits.
For the sum of its digits to equal 1, the number must consist of 1s followed by zeros, making it a multiple of 10, and therefore not a prime number.
For the sum of its digits to equal itself, the number must consist of only one digit (itself).
Therefore, the only Harshad prime numbers are the single-digit primes: 2, 3, 5, and 7.
No, not all factorials are Harshad numbers.
Some small factorials, like 3! = 6 or 4! = 24, are Harshad numbers because they are divisible by the sum of their digits.
But 432! is the first factorial that is not a Harshad number.
For each integer, calculate the sum of its digits.
Test if dividing the integer by this sum results in a remainder of zero; if so, it is a Harshad number.
Here is some pseudocode.function harshad(n) {
s ← 0
x ← n
while x > 0 {
s ← s + (x % 10)
x ← x div 10
}
return (n % s = 0)
}
dCode retains ownership of the "Harshad Number" source code. Any algorithm for the "Harshad Number" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Harshad Number" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Harshad Number" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Harshad Number" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Harshad Number on dCode.fr [online website], retrieved on 2026-01-16,