OFFSET
1,3
COMMENTS
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
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
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
For n = 5:
n in base 2 = [1, 0, 1] -> digitSum(5, 2) = 2.
n in base 3 = [1, 2] -> digitSum(5, 3) = 3.
n in base 4 = [1, 1] -> digitSum(5, 4) = 2.
Base 2 has the smallest sum of the digits for n = 5 ->
therefore a(5) = 2.
For n = 7:
n in base 2 = [1, 1, 1] -> digitSum(7, 2) = 3.
n in base 3 = [2, 1] -> digitSum(7, 3) = 3.
n in base 4 = [1, 3] -> digitSum(7, 4) = 4.
n in base 5 = [1, 2] -> digitSum(7, 5) = 3.
n in base 6 = [1, 1] -> digitSum(7, 6) = 2.
Base 6 has the smallest sum of the digits for n = 7 ->
therefore a(7) = 6.
MAPLE
f:= proc(n) local F, t, d, bmin, s, r, b;
F:= ifactors(n)[2];
d:= igcd(seq(t[2], t=F));
if d > 1 then return mul(t[1]^(t[2]/d), t=F) fi;
F:= ifactors(n-1)[2];
d:= igcd(seq(t[2], t=F));
if d=1 then bmin:= n-1 else bmin:= mul(t[1]^(t[2]/d), t=F) fi;
for s in numtheory:-divisors(n) do
r:= n/s-1;
F:= ifactors(s)[2];
d:= igcd(seq(t[2], t=F));
b:= mul(t[1]^(t[2]/d), t=F);
if b < bmin and r = b^padic:-ordp(r, b) then bmin:= b fi
od;
bmin;
end proc:
map(f, [$1..100]); # Robert Israel, Dec 05 2019
MATHEMATICA
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 *)
PROG
(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};
CROSSREFS
KEYWORD
AUTHOR
Haris Ziko, Nov 21 2019
EXTENSIONS
More terms from Giovanni Resta, Nov 22 2019
STATUS
approved