OFFSET
1,1
COMMENTS
A number m is a Niven number in base b if the sum of its base-b digits divides m. The number 1 is a Niven number in all bases.
Note that in most cases, especially as n becomes larger, these are fairly round numbers. For instance, a(39) = 2^10 * 3^3 * 5^2 * 7^2 * 11.
LINKS
Bert Dobbelaere, Table of n, a(n) for n = 1..54 (terms 1..39 from T. D. Noe)
EXAMPLE
10 is a Niven number for bases 1 to 3 because in those bases 10 is written as 1111111111, 1010, 101 and the sum of the digits is 10, 2, and 2, which all divide 10.
MATHEMATICA
nn = 20; t = Table[0, {nn}]; found = 0; n = 1; While[found < nn, n++; b = 2; While[s = Total[IntegerDigits[n, b]]; s < n && Mod[n, s] == 0, b++]; If[s == n, b = 0]; If[0 < b-1 <= nn && t[[b-1]] == 0, t[[b-1]] = n; found++]]; t
PROG
(PARI) mysumd(n, b) = if (b==1, n, sumdigits(n, b));
isniven(n, b) = (n % mysumd(n, b)) == 0;
isok(k, n) = {for (b = 1, n, if (! isniven(k, b), return (0)); ); ! isniven(k, n+1); }
a(n) = {my(k = 1); while (! isok(k, n), k++); k; } \\ Michel Marcus, Oct 09 2018
CROSSREFS
KEYWORD
nonn,hard,base
AUTHOR
T. D. Noe, May 30 2013
STATUS
approved