cp's OEIS Frontend

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.

A284120 Permutation of the positive integers: a(n) = A258746(A117120(n)) = A117120(A258746(n)).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 9, 8, 11, 10, 13, 12, 15, 14, 18, 19, 16, 17, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 37, 36, 39, 38, 33, 32, 35, 34, 45, 44, 47, 46, 41, 40, 43, 42
Offset: 1

Views

Author

Yosu Yurramendi, Mar 20 2017

Keywords

Comments

The permutation is self-inverse. Except for fixed points 1, 2, 3, 4, 5, 6, 7 it consists completely of 2-cycles: (10,11), (12,13), (14,15), (16,18), (17,19), (20,22), (21,23), (24,26), (25,27), (28,30), (29,31), (32,37), (33,36), (34,39), (35,38), (45,40), ...
{A000027, A258746, A117120, a = A258746(A117120)} form a Klein 4-group.

Programs

  • Mathematica
    A[n_]:= If[n<4, n, If[EvenQ[n], 2A[n/2] + 1, 2A[(n - 1)/2]]]; a[n_]:= If[n<4,n,If[OddQ[Floor[Log2[n]]], If[EvenQ[n], 2a[n/2], 2a[(n - 1)/2] + 1], If[EvenQ[n], 2a[n/2] + 1, 2a[(n - 1)/2]]]]; Table[a[A[n]],{n,50}] (* Indranil Ghosh, Mar 21 2017 *)
  • PARI
    A(n) = if(n<4, n, if(n%2, 2*A(n\2), 2*A(n/2)+1));
    a(n) = if(n<4, n, if(logint(n, 2)%2, if(n%2, 2*a(n\2) + 1, 2*a(n/2)), if(n%2, 2*a(n\2), 2*a(n/2) + 1)));
    for(n=1, 50, print1(a(A(n)),", ")) \\ Indranil Ghosh, Mar 21 2017, modified by Charles R Greathouse IV
  • R
    maxrow <- 6 # by choice
    a <- 1:7
    for(m in 2:maxrow) for(k in 0:(2^m-1)) {
      if(m%%2 == 0) {a[2^(m+1)+2*k  ] <- 2*a[2^m+k]+1
                     a[2^(m+1)+2*k+1] <- 2*a[2^m+k]  }
      else          {a[2^(m+1)+2*k  ] <- 2*a[2^m+k]
                     a[2^(m+1)+2*k+1] <- 2*a[2^m+k]+1}
    }
    a