Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #28 Dec 05 2019 17:42:36
%S 1,1,2,2,2,2,6,2,3,2,10,2,12,7,14,2,2,2,18,2,20,11,22,2,5,5,3,3,28,3,
%T 30,2,2,2,34,6,6,19,38,2,40,6,42,22,44,23,46,2,7,5,50,26,52,3,54,7,56,
%U 29,58,30,60,31,62,2,2,2,66,2,68,35,70,2,72,37,74
%N The smallest base b where the sum of the digits for the number n in the base b is the smallest, with 1 < b < n and a(1) = a(2) = 1.
%C The smallest sum of digits corresponding to a(n) is equal to 2-A075802(n), i.e., it is 1 when n is 1 or a perfect power and 2 otherwise. - _Giovanni Resta_, Nov 22 2019
%C a(n)=n-1 if and only if n is in A088905 but not in A001597. a(n)<= n/2 if n is even. - _Robert Israel_, Dec 05 2019
%H Robert Israel, <a href="/A329814/b329814.txt">Table of n, a(n) for n = 1..10000</a>
%e For n = 5:
%e n in base 2 = [1, 0, 1] -> digitSum(5, 2) = 2.
%e n in base 3 = [1, 2] -> digitSum(5, 3) = 3.
%e n in base 4 = [1, 1] -> digitSum(5, 4) = 2.
%e Base 2 has the smallest sum of the digits for n = 5 ->
%e therefore a(5) = 2.
%e For n = 7:
%e n in base 2 = [1, 1, 1] -> digitSum(7, 2) = 3.
%e n in base 3 = [2, 1] -> digitSum(7, 3) = 3.
%e n in base 4 = [1, 3] -> digitSum(7, 4) = 4.
%e n in base 5 = [1, 2] -> digitSum(7, 5) = 3.
%e n in base 6 = [1, 1] -> digitSum(7, 6) = 2.
%e Base 6 has the smallest sum of the digits for n = 7 ->
%e therefore a(7) = 6.
%p f:= proc(n) local F, t,d,bmin,s,r,b;
%p F:= ifactors(n)[2];
%p d:= igcd(seq(t[2],t=F));
%p if d > 1 then return mul(t[1]^(t[2]/d),t=F) fi;
%p F:= ifactors(n-1)[2];
%p d:= igcd(seq(t[2],t=F));
%p if d=1 then bmin:= n-1 else bmin:= mul(t[1]^(t[2]/d),t=F) fi;
%p for s in numtheory:-divisors(n) do
%p r:= n/s-1;
%p F:= ifactors(s)[2];
%p d:= igcd(seq(t[2],t=F));
%p b:= mul(t[1]^(t[2]/d),t=F);
%p if b < bmin and r = b^padic:-ordp(r,b) then bmin:= b fi
%p od;
%p bmin;
%p end proc:
%p map(f, [$1..100]); # _Robert Israel_, Dec 05 2019
%t a[n_] := Block[{b=1, r=n, t}, Do[t = Plus @@ IntegerDigits[n, i]; If[t < r, r=t; b=i], {i, 2, n-1}]; b]; Array[a, 75] (* _Giovanni Resta_, Nov 22 2019 *)
%o (PARI) a(n)={my(best_b=1, best_dig_sum=n); if(n>1, for(b=2, n-1, dig_sum=sumdigits(n, b); if(best_dig_sum>dig_sum, best_dig_sum=dig_sum; best_b=b))); best_b};
%Y Cf. A001597, A075802, A088905.
%K nonn,base,look
%O 1,3
%A _Haris Ziko_, Nov 21 2019
%E More terms from _Giovanni Resta_, Nov 22 2019