%I #26 May 07 2024 07:05:38
%S 11,7,5,4,3,11,2,2,11,13,1,8,1,1,1,1,1,161,1,8,5,1,1,4,1,1,7,1,1,13,1,
%T 1,1,1,1,83,1,1,1,4,1,4,1,1,11,1,1,2,1,5,1,1,1,537,1,1,1,1,1,83,1,1,3,
%U 1,1,1,1,1,1,5,1,68,1,1,1,1,1,1,1,2,7,1,1,2,1,1,1,1,1,211,1,1,1,1,1,1,1,1,1
%N a(n) = smallest k such that k*n is not a Niven (or Harshad) number.
%C Niven (or Harshad) numbers are numbers that can be divided by the sum of their digits.
%C If n is not a Niven number then a(n) is obviously 1. Some terms are rather large: a(108) = 3611, a(540) = 537037; see also A144375 and A144376.
%C Does a(n) exist for all n? - _Klaus Brockhaus_, Sep 19 2008
%C a(n) should exist for all n since the density of the Niven numbers is zero and it has been proved that arbitrarily large gaps exist between Niven numbers. [_Sergio Pimentel_, Sep 20 2008]
%C Let N be the number formed by concatenating R copies of n, where R is the smallest power of 10 that exceeds n. Then N is a multiple of n, but not a Niven number; since R divides the sum of the digits of N, but R does not divide N. - _David Radcliffe_, Oct 06 2014
%H Amiram Eldar, <a href="/A144262/b144262.txt">Table of n, a(n) for n = 1..10000</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/HarshadNumber.html">Harshad Number</a>
%e a(2) = 7 since 2, 4, 6, 8, 10 and 12 are all Niven numbers; but 7*2 = 14 is not.
%t a[n_] := Module[{k = 1}, While[Divisible[k*n, Plus @@ IntegerDigits[k*n]], k++]; k]; Array[a, 100] (* _Amiram Eldar_, Sep 05 2020 *)
%o (PARI)
%o digitsum(n) = {local(s=0); while(n, s+=n%10; n\=10); s}
%o {for(n=1, 100, k=1; while((p=k*n)%digitsum(p)==0, k++); print1(k, ","))} /* _Klaus Brockhaus_, Sep 19 2008 */
%o (Python)
%o def a(n):
%o kn = n
%o while kn % sum(map(int, str(kn))) == 0: kn += n
%o return kn//n
%o print([a(n) for n in range(1, 100)]) # _Michael S. Branicky_, Nov 07 2021
%Y Cf. A005349 (Niven numbers), A144261 (smallest k such that k*n is a Niven number), A144375 (records in A144262), A144376 (where records occur in A144262).
%K base,nonn
%O 1,1
%A _Sergio Pimentel_, Sep 16 2008
%E Edited by _Klaus Brockhaus_, Sep 19 2008