%I #7 Aug 28 2018 19:36:18
%S -1,0,1,0,-1,1,-1,1,-1,1,0,0,-1,-1,-1,1,0,1,-1,1,0,1,-1,-1,0,-1,1,-1,
%T 0,-1,1,1,-1,0,-1,1,-1,1,-1,-1,1,1,0,1,1,-1,1,1,-1,-1,-1,0,0,1,1,1,-1,
%U -1,1,1,-1,1,-1,1,-1,0,-1,1,1,-1,1,1,-1,-1,1,1,-1,0,1,-1,1,0,-1,-1,-1,1,1,-1,1,1,0,-1,-1,1,-1,1,1,0,-1,1,-1,1,1,1,-1
%N Direction from n-th perfect power to closest prime (-1 if down, 1 if up, 0 if two primes are closest).
%F Sign(n-th perfect power - closest prime) or 0 if two primes are closest.
%e The 7th perfect power (A001597) is 27. The closest prime to 27 is 29. sign(27-29)=-1, so a(7)=-1. The 11th perfect power is 64. There is no single closest prime to 64, since two primes are closest, namely 61 and 67, so a(11)=0.
%t NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; PrevPrim[n_] := Block[{k = n - 1}, While[ !PrimeQ[k], k-- ]; k]; pp = Select[ Range[10000], !PrimeQ[ # ] && Apply[ GCD, Last[ Transpose[FactorInteger[ # ]]]] > 1 & ]; Join[{-1}, Sign[ Table[ NextPrim[pp[[n]]] - pp[[n]], {n, 1, 124}] - Table[ pp[[n]] - PrevPrim[pp[[n]]], {n, 1, 124}]]]
%t ppcp[n_]:=Module[{a=NextPrime[n,-1],b=NextPrime[n]},Which[n-a==b-n,0,n-a < b-n,1,True,-1]]; ppcp/@Join[{1},Select[Range[8000],GCD@@FactorInteger[#][[All,2]]>1&]] (* _Harvey P. Dale_, Aug 28 2018 *)
%Y Cf. A001597.
%K sign
%O 1,1
%A _Neil Fernandez_, Oct 12 2002
%E Edited by _Robert G. Wilson v_, Oct 13 2002