OFFSET
0,3
COMMENTS
Agrees with A284048 (which requires nontrivial prime powers) for indices n = 1..17. We remark that n = 17 is the smallest integer such that one can arrange the numbers 1 through n in a cycle such that any two neighbors sum to a perfect power, and the same is possible for any larger integer. To get this cycle for n = 17, one must use insert (11, 16, 9, 7) between a(7) = 14 and a(8) = 2; then the 17th term would be the current a(13) = 8 that can be "connected" to a(1) = 1 to close the cycle. Alternatively, if one allows for terms >= 0, then the "greedy" solution starting with a(0) = 1 would have a(4) = 0 (after a(3) = 4), followed by 8, and have all integers up to 17 at a(17) = 15 that could be "connected" to a(0). - M. F. Hasler, May 05 2026
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
MATHEMATICA
f[n_] := n == 1 || GCD @@ Last /@ FactorInteger[n] > 1; g[l_List] := Block[{k = 1}, While[MemberQ[l, k] || ! f[k + l[[ -1]]], k++ ]; Append[l, k]]; Nest[g, {0}, 73] (* Ray Chandler, Jan 22 2007 *)
PROG
(PARI) A127397_first(N, S=0, U=0)={vector(N, n, if(n>2, for(k=S, oo, !bittest(U, k-S)&& ispower(k+N)&& [N=k, break]), N=n-1); if(N>S, U+=1<<(N-S), S+=n=valuation(U+2, 2); U>>=n); N)} \\ M. F. Hasler, May 05 2026
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Leroy Quet, Jan 12 2007
EXTENSIONS
Extended by Ray Chandler, Jan 22 2007
STATUS
approved
