login
Least Niven number for all bases from 1 to n but not for base n+1.
6

%I #23 Oct 12 2018 04:27:18

%S 3,34,10,21,8,20,12,456,168,216,40,1764,24,432,2772,780,1008,5640,720,

%T 88452,15840,840,3360,14040,288288,117600,338400,13860,40320,6283200,

%U 100800,2106720,7698600,26943840,19768320,202799520,12972960,242260200,372556800

%N Least Niven number for all bases from 1 to n but not for base n+1.

%C 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.

%C 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.

%H Bert Dobbelaere, <a href="/A225427/b225427.txt">Table of n, a(n) for n = 1..54</a> (terms 1..39 from T. D. Noe)

%e 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.

%t 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

%o (PARI) mysumd(n, b) = if (b==1, n, sumdigits(n, b));

%o isniven(n, b) = (n % mysumd(n, b)) == 0;

%o isok(k, n) = {for (b = 1, n, if (! isniven(k, b), return (0));); ! isniven(k, n+1);}

%o a(n) = {my(k = 1); while (! isok(k, n), k++); k;} \\ _Michel Marcus_, Oct 09 2018

%Y Cf. A226171 (first base for which n is not a Niven number).

%K nonn,hard,base

%O 1,1

%A _T. D. Noe_, May 30 2013