This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A346036 #27 Sep 25 2021 23:09:11 %S A346036 0,0,1,2,2,4,5,4,6,8,7,10,10,10,13,12,12,14,17,16,18,18,17,22,22,20, %T A346036 25,24,24,28,29,24,26,32,31,34,32,32,35,38,36,40,35,40,40,40,39,44,46, %U A346036 42,49,50,44,52,51,52,52,54,51,54,58,56,59,54,54,64,61,60 %N A346036 Number of swaps needed to return the recursive transform T(k) = concatenate(reverse(k), len(k) + 1) to the tuple 1, 2, ..., n. %e A346036 For n=7, the T transforms give tuple 6,4,2,1,3,5,7 (triangle A220073 row 7) which requires a(7) = 5 swaps to return to 1,2,3,4,5,6,7. %o A346036 (Python) %o A346036 def swaps(l, start = 0): %o A346036 if len(l) == 0: %o A346036 return 0 %o A346036 n = start + 1 %o A346036 if l[0] != n: %o A346036 for i, x in enumerate(l): %o A346036 if x == n: %o A346036 l[0], l[i] = l[i], l[0] %o A346036 return 1 + swaps(l[1:], n) %o A346036 else: %o A346036 raise %o A346036 else: %o A346036 return swaps(l[1:], n) %o A346036 def T(l): %o A346036 n = len(l) %o A346036 l.reverse() %o A346036 l.append(n + 1) %o A346036 return l %o A346036 if __name__ == "__main__": %o A346036 l = [ ] %o A346036 for n in range(1, 100): %o A346036 l = T(l) %o A346036 n_swaps = swaps(l[:]) %o A346036 print("{}, ".format(n_swaps), end="") %o A346036 (PARI) a(n) = my(h=n>>1); n - #permcycles(vectorsmall(n,i, abs(2*i-n) + (i<=h))); \\ _Kevin Ryde_, Jul 23 2021 %Y A346036 Cf. A220073. %K A346036 nonn %O A346036 1,4 %A A346036 _Emanuel Landeholm_, Jul 02 2021