OFFSET
1,2
LINKS
EXAMPLE
a(24) = 11:
Factorization Sum of Digital Roots
2 * 2 * 2 * 3 2 + 2 + 2 + 3 = 9
2 * 3 * 4 2 + 3 + 4 = 9
2 * 2 * 6 2 + 2 + 6 = 10
4 * 6 4 + 6 = 10
3 * 8 3 + 8 = 11
2 * 12 2 + 1 + 2 = 5
24 2 + 4 = 6
Result is 11.
PROG
(PARI) fcnt(n, m) = {my(d = divisors(n), v = List(select(x->((x>1) && (x<=m)), d)), list = List()); for (k=1, #v, my(x = fcnt(n/v[k], v[k])); if (#x==0, listput(list, [v[k]]), for (j=1, #x, listput(list, concat(v[k], x[j])))); ); list; }
factoriz(n) = {if (n==1, return ([[1]])); my(list = fcnt(n, n), res = List()); for (i=1, #list, my(vi=list[i]); if (vecprod(vi) == n, listput(res, vi)); ); Vec(res); } \\ A162247
a(n) = {my(v = factoriz(n)); vecmax(vector(#v, k, vecsum(apply(x->(x-1)%9+1, v[k])))); } \\ Michel Marcus, Jun 06 2022
(Python)
def drs(x, m):
if x == 0:
return 0
return ((x - 1) % m) + 1
def a(n):
DRS = [drs(x, 9) for x in range(0, n + 1)]
for a in range(2, n):
da = DRS[a]
for b in range(2, 1 + (n // a)):
ab = a * b
if ab > n:
break
else:
x = da + DRS[b]
if DRS[ab] < x:
DRS[ab] = x
return DRS[1: n + 1][-1]
CROSSREFS
KEYWORD
nonn,base
AUTHOR
DarĂo Clavijo, May 02 2022
STATUS
approved