login
If the highest power of the prime p that divides n is p^b(n,p), then a(n) is the least nonnegative integer that equals some sum{p|n} (+or-)p^b(n, p).
1

%I #13 Aug 28 2020 08:06:54

%S 0,2,3,4,5,1,7,8,9,3,11,1,13,5,2,16,17,7,19,1,4,9,23,5,25,11,27,3,29,

%T 0,31,32,8,15,2,5,37,17,10,3,41,2,43,7,4,21,47,13,49,23,14,9,53,25,6,

%U 1,16,27,59,2,61,29,2,64,8,6,67,13,20,0,71,1,73,35,22,15,4,8,79,11,81,39,83

%N If the highest power of the prime p that divides n is p^b(n,p), then a(n) is the least nonnegative integer that equals some sum{p|n} (+or-)p^b(n, p).

%H Robert Israel, <a href="/A140523/b140523.txt">Table of n, a(n) for n = 1..10000</a>

%e 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.

%p f:= proc(n) local F,V,i;

%p F:= map(t -> t[1]^t[2],ifactors(n)[2]);

%p V:= {F[1]};

%p for i from 2 to nops(F) do

%p V:= map(t -> (t+F[i],t-F[i]), V);

%p od:

%p min(map(abs,V))

%p end proc:

%p f(1):= 0:

%p map(f, [$1..100]); # _Robert Israel_, Sep 12 2018

%t 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];

%t f[1] = 0;

%t Array[f, 100] (* _Jean-François Alcover_, Aug 28 2020, after _Robert Israel_ *)

%K nonn

%O 1,2

%A _Leroy Quet_, Jul 02 2008

%E Extended by _Ray Chandler_, Jun 25 2009