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 A347945 #108 Oct 28 2021 06:41:47 %S A347945 0,2,3,1,6,7,5,10,11,8,14,15,4,18,19,13,22,23,16,26,27,12,30,31,21,34, %T A347945 35,24,38,39,17,42,43,29,46,47,32,50,51,9,54,55,37,58,59,40,62,63,28, %U A347945 66,67,45,70,71,48,74,75,33,78,79,53,82,83,56 %N A347945 To get {a(n)}, start with the nonnegative integers sequence f() and, for each y>=0, shift the f(y) to position f(2y) and reset indices. %C A347945 To get {a(n)}, we use the working sequences f_x(y), where y is the index and x is both, the x-th working sequence and a control variable. x=0,1,2,3,... up to infinity. %C A347945 f_x(y) = f_(x-1)(x) if y = 2x, f_(x-1)(y+1) if x <= y < 2x, and s_(x-1)(y) otherwise. %C A347945 Start with the sequence of nonnegative integers %C A347945 {f(y)} = 0,1,2,3,4,5,6,7,8,9,10,11,12,... %C A347945 The first index is 0: For f(y=0), nothing is changed, since f(2*0=0), so we still have %C A347945 {f_0(y)} = 0,1,2,3,4,5,6,7,8,9,10,11,12,... %C A347945 For x=1: Shift f(1)=1 to f(2*1)=f(2), and all f(1<y<=2) to f(y-1): f(2)=2 to f(1), leaving %C A347945 {f_1(y)} = 0,2,1,3,4,5,6,7,8,9,10,11,12,... %C A347945 For x=2: Shift f(2)=1 to f(2*2)=f(4), and all f(1<y<=4) to f(y-1), leaving %C A347945 {f_2(y)} = 0,2,3,4,1,5,6,7,8,9,10,11,12,... %C A347945 Iterating the "cyclic shifting" indefinitely produces {a(n)}. %C A347945 . %C A347945 Visualization of the term index-position shift: %C A347945 f_1: 0 1 2 3 4 5 6 7 8 9 10 11 12 ... %C A347945 └+1─^ %C A347945 f_2: 0 2 1 3 4 5 6 7 8 9 10 11 12 ... %C A347945 └──+2──^ %C A347945 f_3: 0 2 3 4 1 5 6 7 8 9 10 11 12 ... %C A347945 └───+3────^ %C A347945 f_4: 0 2 3 1 5 6 4 7 8 9 10 11 12 ... %C A347945 └─────+4─────^ %C A347945 f_5: 0 2 3 1 6 4 7 8 5 9 10 11 12 ... %C A347945 └───────+5───────^ %C A347945 f_6: 0 2 3 1 6 7 8 5 9 10 4 11 12 ... %C A347945 . %C A347945 In the Formula section, formulas (2) and (3) (which build pairs of terms with a certain repeating spacing and difference, unlike formula (1)) give the terms with the single most f(x) to f(2x) shifts. %C A347945 Some terms f(y) only get shifted to f(y-1), decreasing their final index n; other terms f(y) change position to f(2y) multiple times. %C A347945 The value "t" in formulas (1), (2) and (3) gives the number of f(2y) shifts "s" of the resulting terms: For (1): s = t, for (2),(3): s = t-1. %C A347945 E.g., the terms f(y) for the formulas (2) and (3) with t=1 (e.g., 2,3,6,7,10,11,...) only get shifted to f(y-1), e.g., f(y)=14=a(10), decreasing its index n from 14 to 10. %C A347945 Other terms f(y) for formulas (2) and (3) with t>1 change position to f(2y) one or multiple times; e.g., for formula (2) t=3, k=1: f(y)=28=a(48) increases its position 2 times from its original y=28 up to n=48. %C A347945 The number of times that the terms f(y) for formula (1) change position to f(2y) is t. E.g., t=5: f(y)=20=a(120) changes positions 5 times, up to n=120. %H A347945 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers</a> %F A347945 To obtain all terms there are three formulas. %F A347945 For any t=1,2,3,... and k=0,1,2,3,... constellation: %F A347945 (1) a((3^t - 3)/2) = (2^(t+2) + (-1)^(t-1) - 9)/6. %F A347945 (2) a(k*3^t + (5*3^(t-1)-3)/2) = k*2^(t+1) + 2^t + (2^(t+2) + (-1)^(t-1) - 9)/6. %F A347945 (3) a(k*3^t + (7*3^(t-1)-3)/2) = k*2^(t+1) + 2^t + (2^(t+3) - (-1)^(t-1) - 9)/6. %e A347945 Formula (1) has no control value "k" and produces small values (terms) for large index numbers n, compared to formulas (2) and (3). %e A347945 E.g.: %e A347945 For formula (1) t=5: a(363)=41. %e A347945 For formula (2) t=1, k=100: a(301)=402. %e A347945 Formula (1) produces the "Generalized Jacobsthal numbers" as a subsequence "s": s(A029858(t))=A084639(t), and the differences between those terms are the "Jacobsthal numbers" A001045. %o A347945 (PARI) shiftv(v, n) = {my(w = v); for (i=1,n-1, w[i] = v[i];); for (i=n, 2*n-1, w[i] = v[i+1];); w[2*n] = v[n]; w;} %o A347945 lista(nn) = {my(v = [1..nn], va); for (n=1, nn\2, va = shiftv(v, n); v = va;); concat(0, vector(#v\2, k, v[k]));} \\ _Michel Marcus_, Sep 21 2021 %o A347945 (PARI) a(n) = n++; my(c=1,r); while([n,r]=divrem(n,3);r==1, c++); n<<(c+1) + (r<<1+1)<<c\3 - 1; \\ _Kevin Ryde_, Oct 09 2021 %Y A347945 Cf. A001045 (Jacobsthal numbers), A084639 (generalized Jacobsthal numbers), A029858, A254046, A253786. %K A347945 nonn %O A347945 0,2 %A A347945 _Marc Morgenegg_, Sep 20 2021