In mathematics, a harshad number (or Niven number) in a given number base is an integer that is divisible by the sum of its digits when written in that base.
Harshad numbers in base n are also known as n-harshad (or n-Niven) numbers.
Harshad numbers were defined by D. R. Kaprekar, a mathematician from India. The word "harshad" comes from the Sanskrit (joy) + (give), meaning joy-giver. The term "Niven number" arose from a paper delivered by Ivan M. Niven at a conference on number theory in 1977.
Stated mathematically, let X be a positive integer with m digits when written in base n, and let the digits be (). (It follows that must be either zero or a positive integer up to n-1.) X can be expressed as
X is a harshad number in base n if:
A number which is a harshad number in every number base is called an all-harshad number, or an all-Niven number. There are only four all-harshad numbers: 1, 2, 4, and 6. The number 12 is a harshad number in all bases except octal.
The number 18 is a harshad number in base 10, because the sum of the digits 1 and 8 is 9, and 18 is divisible by 9.
The Hardy–Ramanujan number (1729) is a harshad number in base 10, since it is divisible by 19, the sum of its digits (1729 = 19 × 91).
The number 19 is not a harshad number in base 10, because the sum of the digits 1 and 9 is 10, and 19 is not divisible by 10.
In base 10, every natural number expressible in the form 9Rnan, where the number Rn consists of n copies of the single digit 1, n > 0, and an is a positive integer less than 10n and multiple of n, is a harshad number. (R. D’Amico, 2019). The number 9R3a3 = 521478, where R3 = 111, n = 3 and a3 = 3×174 = 522, is a harshad number; in fact, we have: 521478/(5+2+1+4+7+8) = 521478/27 = 19314.
Harshad numbers in base 10 form the sequence:
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, ... .