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.

A153154 Permutation of natural numbers: A059893-conjugate of A006068.

Original entry on oeis.org

0, 1, 3, 2, 7, 4, 5, 6, 15, 8, 9, 14, 11, 12, 13, 10, 31, 16, 17, 30, 19, 28, 29, 18, 23, 24, 25, 22, 27, 20, 21, 26, 63, 32, 33, 62, 35, 60, 61, 34, 39, 56, 57, 38, 59, 36, 37, 58, 47, 48, 49, 46, 51, 44, 45, 50, 55, 40, 41, 54, 43, 52, 53, 42, 127, 64, 65, 126, 67, 124
Offset: 0

Views

Author

Antti Karttunen, Dec 20 2008

Keywords

Comments

A002487(1+a(n)) = A020651(n) and A002487(a(n)) = A020650(n). So, it generates the enumeration system of positive rationals based on Stern's sequence A002487. - Yosu Yurramendi, Feb 26 2020

Crossrefs

Inverse: A153153. a(n) = A059893(A006068(A059893(n))).

Programs

  • R
    maxn <- 63 # by choice
    a <- c(1,3,2)
    #
    for(n in 2:maxn){
      a[2*n] <- 2*a[n] + 1
      if(n%%2==0) a[2*n+1] <- 2*a[n+1]
      else        a[2*n+1] <- 2*a[n-1]
    }
    (a <- c(0,a))
    # Yosu Yurramendi, Feb 26 2020
    
  • R
    # Given n, compute a(n) by taking into account the binary representation of n
    maxblock <- 8 # by choice
    a <- c(1, 3, 2)
    for(n in 4:2^maxblock){
      ones <- which(as.integer(intToBits(n)) == 1)
      nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
      anbit <- nbit
      for(i in 2:(length(anbit) - 1))
        anbit[i] <- bitwXor(anbit[i], anbit[i - 1])  # ?bitwXor
      anbit[0:(length(anbit) - 1)] <- 1 - anbit[0:(length(anbit) - 1)]
      a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
    }
    (a <- c(0, a))
    # Yosu Yurramendi, Oct 04 2021

Formula

From Yosu Yurramendi, Feb 26 2020: (Start)
a(1) = 1, for all n > 0 a(2*n) = 2*a(n) + 1, a(2*n+1) = 2*a(A065190(n)).
a(1) = 1, a(2) = 3, a(3) = 2, for all n > 1 a(2*n) = 2*a(n) + 1, and if n even a(2*n+1) = 2*a(n+1), else a(2*n+1) = 2*a(n-1).
a(n) = A054429(A231551(n)) = A231551(A065190(n)) = A284459(A054429(n)) =
A332769(A284459(n)) = A258996(A154437(n)). (End)