%I #33 Feb 07 2026 16:30:11
%S 0,1,2,3,5,4,7,6,10,8,12,9,15,11,17,13,20,14,22,16,25,18,27,19,30,21,
%T 32,23,35,24,37,26,40,28,42,29,45,31,47,33,50,34,52,36,55,38,57,39,60,
%U 41,62,43,65,44,67,46,70,48,72,49,75,51,77,53,80,54,82,56,85,58,87
%N Let k = n/2 + floor(n/4) if n is even, otherwise (3n+1)/2; then a(n) = A093545(k).
%C This is a permutations of the nonnegative integers.
%C A093545 is the inverse of A340615.
%C Some of the cycles of this permutation are: (0),(1),(2),(3),(5 4),(7 6),(10 12 15 13 11 9 8),(17 14),(20 25 21 18 22 27 23 19 16),... .
%C A340615 and A342131 are permutations, constructed by a small modification of Collatz function (A014682). This sequence relates these permutations which each other: A340615(a(n)) = A342131(n).
%H Harvey P. Dale, <a href="/A340709/b340709.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers.</a>
%H <a href="/index/Rec#order_10">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,1,0,1,0,0,0,-1).
%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem.</a>
%F a(4*m) = 5*m.
%F a(2+4*m) = 2+5*m.
%F a(1+6*m) = 1+5*m.
%F a(3+6*m) = 3+5*m.
%F a(4+6*m) = 4+5*m.
%F a(n) = -2*a(n-1) - 3*a(n-2) - 4*a(n-3) - 4*a(n-4) - 4*a(n-5) - 3*a(n-6) - 2*a(n-7) - a(n-8) + 25n - 101 for n >= 8.
%F a(n) = A093545(A342131(n)).
%F G.f.: x*(1 + 2*x + 3*x^2 + 5*x^3 + 3*x^4 + 5*x^5 + 2*x^6 + 3*x^7 + x^8)/(1 - x^4 - x^6 + x^10). - _Stefano Spezia_, Mar 01 2021
%t LinearRecurrence[{0,0,0,1,0,1,0,0,0,-1},{0,1,2,3,5,4,7,6,10,8},80] (* _Harvey P. Dale_, Feb 07 2026 *)
%o (MATLAB)
%o function a = A340709(max_n)
%o for n = 1:max_n*10
%o k = (n-1)+floor(((n-1)+1)/5);
%o m = n-1;
%o if floor(k/2) == k/2
%o A340615(n) = k/2;
%o else
%o A340615(n) = (k*3+1)/2;
%o end
%o if floor(m/2) == m/2
%o b(n) = m/2+floor(m/4);
%o else
%o b(n) = (m*3+1)/2;
%o end
%o end
%o for n = 1:(length(A340615)/10)
%o a(n) = find(A340615==b(n))-1;
%o end
%o end
%Y Cf. A014682, A340615, A093545, A342131.
%K nonn,easy
%O 0,3
%A _Thomas Scheuerle_, Jan 16 2021