OFFSET
1,2
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
60 has the prime factorization: 2^2 * 3^1 * 5^1. The least nonnegative integer that is made by either adding or subtracting the prime powers in this prime factorization is: a(60) = + 2^2 + 3^1 - 5^1 = 2.
MAPLE
f:= proc(n) local F, V, i;
F:= map(t -> t[1]^t[2], ifactors(n)[2]);
V:= {F[1]};
for i from 2 to nops(F) do
V:= map(t -> (t+F[i], t-F[i]), V);
od:
min(map(abs, V))
end proc:
f(1):= 0:
map(f, [$1..100]); # Robert Israel, Sep 12 2018
MATHEMATICA
f[n_] := Module[{F, V}, F = Power @@@ FactorInteger[n]; V = {F[[1]]}; Do[V = {# + F[[i]], # - F[[i]]}& /@ V // Flatten, {i, 2, Length[F]}]; V // Abs // Min];
f[1] = 0;
Array[f, 100] (* Jean-François Alcover, Aug 28 2020, after Robert Israel *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Leroy Quet, Jul 02 2008
EXTENSIONS
Extended by Ray Chandler, Jun 25 2009
STATUS
approved