您可能想查看the OEIS page 以了解此序列。
它包含几个代码 sn-ps,例如 Maple 中的这个:
f:= proc(n) option remember;
if isprime(n) then n
else `procname`(add(x[1]*x[2], x = ifactors(n)[2]))
fi
end proc:
f(1):= 0: f(4):= 4:
map(f, [$1..100]); # Robert Israel, Apr 27 2015
我不了解 Maple,但这看起来很像您建议的递归定义。因此,我倾向于说迭代直到达到素数(1 和 4 的特殊情况除外)是最有效的计算方法。
还有一个 Mathematica 脚本,但我完全无法理解:
ffi[x_] := Flatten[FactorInteger[x]] lf[x_] := Length[FactorInteger[x]] ba[x_] := Table[Part[ffi[x], 2*w-1], {w, 1, lf[x]}] ep[x_] := Table[Part[ffi[x], 2*w], {w, 1, lf[x]}] slog[x_] := slog[x_] := Apply[Plus, ba[x]*ep[x]] Table[FixedPoint[slog, w], {w, 1, 128}]
f[n_] := Plus @@ Flatten[ Table[ #[[1]], {#[[2]]}] & /@ FactorInteger@n]; Array[ FixedPoint[f, # ] &, 87] (* Robert G. Wilson v, Jan 18 2006 *)
fz[n_]:=Plus@@(#[[1]]*#[[2]]&/@FactorInteger@n); Array[FixedPoint[fz, #]&, 1000] (* Zak Seidov, Mar 14 2011 *)
This related sequence 给出了达到结果所需的迭代次数。它说只有一个 n