OFFSET
1,1
COMMENTS
Niven (or Harshad) numbers are numbers that can be divided by the sum of their digits.
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.
Does a(n) exist for all n? - Klaus Brockhaus, Sep 19 2008
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]
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
LINKS
Amiram Eldar, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Harshad Number
EXAMPLE
a(2) = 7 since 2, 4, 6, 8, 10 and 12 are all Niven numbers; but 7*2 = 14 is not.
MATHEMATICA
a[n_] := Module[{k = 1}, While[Divisible[k*n, Plus @@ IntegerDigits[k*n]], k++]; k]; Array[a, 100] (* Amiram Eldar, Sep 05 2020 *)
PROG
(PARI)
digitsum(n) = {local(s=0); while(n, s+=n%10; n\=10); s}
{for(n=1, 100, k=1; while((p=k*n)%digitsum(p)==0, k++); print1(k, ", "))} /* Klaus Brockhaus, Sep 19 2008 */
(Python)
def a(n):
kn = n
while kn % sum(map(int, str(kn))) == 0: kn += n
return kn//n
print([a(n) for n in range(1, 100)]) # Michael S. Branicky, Nov 07 2021
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Sergio Pimentel, Sep 16 2008
EXTENSIONS
Edited by Klaus Brockhaus, Sep 19 2008
STATUS
approved