Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I M0481 #175 Nov 26 2024 13:39:16
%S 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,
%T 70,72,80,81,84,90,100,102,108,110,111,112,114,117,120,126,132,133,
%U 135,140,144,150,152,153,156,162,171,180,190,192,195,198,200,201,204
%N Niven (or Harshad, or harshad) numbers: numbers that are divisible by the sum of their digits.
%C Both spellings, "Harshad" or "harshad", are in use. It is a Sanskrit word, and in Sanskrit there is no distinction between upper- and lower-case letters. - _N. J. A. Sloane_, Jan 04 2022
%C z-Niven numbers are numbers n which are divisible by (A*s(n) + B) where A, B are integers and s(n) is sum of digits of n. Niven numbers have A = 1, B = 0. - _Ctibor O. Zizka_, Feb 23 2008
%C A070635(a(n)) = 0. A038186 is a subsequence. - _Reinhard Zumkeller_, Mar 10 2008
%C A049445 is a subsequence of this sequence. - _Ctibor O. Zizka_, Sep 06 2010
%C Complement of A065877; A188641(a(n)) = 1; A070635(a(n)) = 0. - _Reinhard Zumkeller_, Apr 07 2011
%C A001101, the Moran numbers, are a subsequence. - _Reinhard Zumkeller_, Jun 16 2011
%C A140866 gives the number of terms <= 10^k. - _Robert G. Wilson v_, Oct 16 2012
%C The asymptotic density of this sequence is 0 (Cooper and Kennedy, 1984). - _Amiram Eldar_, Jul 10 2020
%C From _Amiram Eldar_, Oct 02 2023: (Start)
%C Named "Harshad numbers" by the Indian recreational mathematician Dattatreya Ramchandra Kaprekar (1905-1986) in 1955. The meaning of the word is "giving joy" in Sanskrit.
%C Named "Niven numbers" by Kennedy et al. (1980) after the Canadian-American mathematician Ivan Morton Niven (1915-1999). During a lecture given at the 5th Annual Miami University Conference on Number Theory in 1977, Niven mentioned a question of finding a number that equals twice the sum of its digits, which appeared in the children's pages of a newspaper. (End)
%D Paul Dahlenberg and T. Edgar, Consecutive factorial base Niven numbers, Fib. Q., 56:2 (2018), 163-166.
%D D. R. Kaprekar, Multidigital Numbers, Scripta Math., Vol. 21 (1955), p. 27.
%D Robert E. Kennedy and Curtis N. Cooper, On the natural density of the Niven numbers, Abstract 816-11-219, Abstracts Amer. Math. Soc., 6 (1985), 17.
%D Robert E. Kennedy, Terry A. Goodman, and Clarence H. Best, Mathematical Discovery and Niven Numbers, The MATYC Journal, Vol. 14, No. 1 (1980), pp. 21-25.
%D József Sándor and Borislav Crstici, Handbook of Number theory II, Kluwer Academic Publishers, 2004, Chapter 4, p. 381.
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%D David Wells, The Penguin Dictionary of Curious and Interesting Numbers. Penguin Books, NY, 1986, 171.
%H N. J. A. Sloane, <a href="/A005349/b005349.txt">Table of n, a(n) for n = 1..11872</a> (all a(n) <= 100000)
%H Bob Albrecht, Don Albers, and Jim Conlan, <a href="https://archive.org/details/1980-07-recreational-computing/page/n57">Problem #22 Two-digit Niven numbers</a>, Programming Problems, Recreational Computing Magazine, Vol. 9, No. 1, Issue 46 (1980), p. 59.
%H Curtis N. Cooper and Robert E. Kennedy, <a href="https://doi.org/10.1155/S0161171285000576">On an asymptotic formula for the Niven numbers</a>, International Journal of Mathematics and Mathematical Sciences, Vol. 8, No. 3 (1985), pp. 537-543.
%H Curtis N. Cooper and Robert E. Kennedy, <a href="http://www.jstor.org/stable/2323194">Chebyshev's inequality and natural density</a>, Amer. Math. Monthly 96 (1989), no. 2, 118-124.
%H Paul Dalenberg and Tom Edgar, <a href="https://www.fq.math.ca/56-2.html">Consecutive factorial base Niven numbers</a>, Fibonacci Quart. (2018) Vol. 56, No. 2, 163-166.
%H Jean-Marie De Koninck and Nicolas Doyon, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL6/Doyon/doyon.html">Large and Small Gaps Between Consecutive Niven Numbers</a>, J. Integer Seqs., Vol. 6, 2003, Article 03.2.5.
%H Nicolas Doyon, <a href="https://www.collectionscanada.gc.ca/obj/s4/f2/dsk3/QQLA/TC-QQLA-24023.pdf">Les fascinants nombres de Niven</a>, Thèse de la faculté des sciences et de génie de l'université Laval, Québec, Novembre 2006 (in French).
%H Ömer Eğecioğlu and Bünyamin Şahin, <a href="https://toc.ui.ac.ir/article_28781.html">On twin EP numbers</a>, Transact. Comb. (2025) Vol. 14, Iss. 4, Art. No. 4, 261-270. See p. 262.
%H Richard K. Guy, <a href="http://www.jstor.org/stable/2691503">The Second Strong Law of Small Numbers</a>, Math. Mag, 63 (1990), no. 1, 3-20.
%H Richard K. Guy, <a href="/A005347/a005347.pdf">The Second Strong Law of Small Numbers</a>, Math. Mag, 63 (1990), no. 1, 3-20. [Annotated scanned copy]
%H Robert E. Kennedy, <a href="https://cms.math.ca/wp-content/uploads/crux-pdfs/Crux_v8n05_May.pdf">Digital sums, Niven numbers, and natural density</a>, Crux Mathematicorum, Vol. 8 (1982), pp. 131-135.
%H Robert E. Kennedy and Curtis N. Cooper, <a href="http://www.jstor.org/stable/2686395">On the natural density of the Niven numbers</a>, The College Mathematics Journal, Vol. 15, No. 4 (Sep., 1984), pp. 309-312.
%H Project Euler, <a href="https://projecteuler.net/problem=387">Harshad Numbers: Problem 387</a>.
%H Terry Trotter, <a href="https://web.archive.org/web/20051108143157/http://www.trottermath.net/numthry/nivennos.html">Niven Numbers for Fun and Profit</a>. [archived page]
%H Gérard Villemin, <a href="http://villemin.gerard.free.fr/Wwwgvmm/Decompos/Harshad.htm">Nombres de Harshad</a> (French).
%H Elaine E. Visitacion, Renalyn T. Boado, Mary Ann V. Doria, and Eduard M. Albay, <a href="https://web.archive.org/web/20190407151217/http://www.dmmmsu-sluc.com/wp-content/uploads/2018/03/CAS-Monitor-2016-2017-1.pdf">On Harshad Number</a>, DMMMSU-CAS Science Monitor (2016-2017) Vol. 15 No. 2, 134-138. [archived]
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Digit.html">Digit</a> and <a href="http://mathworld.wolfram.com/HarshadNumber.html">Harshad Numbers</a>.
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Harshad_number">Harshad number</a>.
%e 195 is a term of the sequence because it is divisible by 15 (= 1 + 9 + 5).
%p s:=proc(n) local N:N:=convert(n,base,10):sum(N[j],j=1..nops(N)) end:p:=proc(n) if floor(n/s(n))=n/s(n) then n else fi end: seq(p(n),n=1..210); # _Emeric Deutsch_
%t harshadQ[n_] := Mod[n, Plus @@ IntegerDigits@ n] == 0; Select[ Range[1000], harshadQ] (* _Alonso del Arte_, Aug 04 2004 and modified by _Robert G. Wilson v_, Oct 16 2012 *)
%t Select[Range[300],Divisible[#,Total[IntegerDigits[#]]]&] (* _Harvey P. Dale_, Sep 07 2015 *)
%o (Haskell)
%o a005349 n = a005349_list !! (n-1)
%o a005349_list = filter ((== 0) . a070635) [1..]
%o -- _Reinhard Zumkeller_, Aug 17 2011, Apr 07 2011
%o (Magma) [n: n in [1..250] | n mod &+Intseq(n) eq 0]; // _Bruno Berselli_, May 28 2011
%o (Magma) [n: n in [1..250] | IsIntegral(n/&+Intseq(n))]; // _Bruno Berselli_, Feb 09 2016
%o (PARI) is(n)=n%sumdigits(n)==0 \\ _Charles R Greathouse IV_, Oct 16 2012
%o (Python)
%o A005349 = [n for n in range(1,10**6) if not n % sum([int(d) for d in str(n)])] # _Chai Wah Wu_, Aug 22 2014
%o (Sage)
%o [n for n in (1..10^4) if sum(n.digits(base=10)).divides(n)] # _Freddy Barrera_, Jul 27 2018
%o (GAP) Filtered([1..230],n-> n mod List(List([1..n],ListOfDigits),Sum)[n]=0); # _Muniru A Asiru_
%Y Cf. A001101, A007602, A007953, A028834, A038186, A049445, A052018, A052019, A052020, A052021, A052022, A065877, A070635, A113315, A188641.
%Y Cf. A001102 (a subsequence).
%Y Cf. A118363 (for factorial-base analog).
%Y Cf. A330927, A154701, A141769, A330928, A330929, A330930 (start of runs of 2, 3, ..., 7 consecutive Niven numbers).
%K nonn,base,nice,easy
%O 1,2
%A _N. J. A. Sloane_, _Robert G. Wilson v_