login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A074332
Direction from n-th perfect power to closest prime (-1 if down, 1 if up, 0 if two primes are closest).
0
-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, 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, -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
OFFSET
1,1
FORMULA
Sign(n-th perfect power - closest prime) or 0 if two primes are closest.
EXAMPLE
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.
MATHEMATICA
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}]]]
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 *)
CROSSREFS
Cf. A001597.
Sequence in context: A266112 A331990 A301849 * A152065 A267870 A267878
KEYWORD
sign
AUTHOR
Neil Fernandez, Oct 12 2002
EXTENSIONS
Edited by Robert G. Wilson v, Oct 13 2002
STATUS
approved