A322522 a(n) is the minimal absolute difference between n and each of the powers of the previous terms; a(1) = 1.
1, 1, 2, 0, 1, 2, 1, 0, 1, 2, 3, 3, 3, 2, 1, 0, 1, 2, 3, 4, 5, 3, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0, 1, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1
Offset: 1
Examples
For n = 4, we have a(4) = 0, because a(3) = 2, and 2^2 - 4 = 0. For n = 6, we have a(6) = 0, because there are only 0, 1 and 2 in the first 5 terms, and therefore the closest power is 2^2 = 4 or 2^3 = 8, with an absolute difference of 2.
Links
- Gabin Kolly, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A301573 (distance from n to the nearest nontrivial power).
Programs
-
Mathematica
comparePowers[n_, m_] := If[n <= 1, m - n, a = n; While[a < m, a *= n]; Min[m - a/n, a - m]]; list = {1}; cleanList = {1}; Do[ list = Append[list, Min[comparePowers[#, Length[list] + 1] & /@ cleanList]]; If[Last[list] > Last[cleanList], cleanList = Append[cleanList, Last[list]]], 9999]; Print[list]
Formula
Let b(n) be the first time that n appears in the sequence; then b(n) ~ n^2.
Comments