login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A063946 Write n in binary and complement second bit (from the left), with a(0)=0 and a(1)=1. 9
0, 1, 3, 2, 6, 7, 4, 5, 12, 13, 14, 15, 8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31, 16, 17, 18, 19, 20, 21, 22, 23, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 96, 97, 98, 99, 100, 101, 102 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

From Yosu Yurramendi, Mar 21 2017: (Start)

It is self-inverse. Except for fixed points 0, 1, it consists completely of 2-cycles: (2^(m+1)+k, 2^(m+1)+2^m+k), m >= 0, 0 <= k < 2^m.

A071766(a(n)) = A229742(n), A229742(a(n)) = A071766(n), n > 0.

A245325(a(n)) = A245326(n), A245326(a(n)) = A245325(n), n > 0.

A065190(a(n)) = a(A065190(n)), n > 0.

A054429(a(n)) = a(A054429(n)) = A117120(n), n > 0.

A258746(a(n)) = a(A258746(n)), n > 0.

A258996(a(n)) = a(A258996(n)), n > 0. (End)

LINKS

Yosu Yurramendi, Table of n, a(n) for n = 0..32767

FORMULA

If 2*2^k <= n < 3*2^k then a(n) = n + 2^k; if 3*2^k <= n < 4*2^k then a(n) = n - 2^k.

a(0)=0, a(1)=1, a(2)=3, a(3) = 2, a(2n) = 2a(n), a(2n+1) = 2a(n) + 1. - Ralf Stephan, Aug 23 2003

EXAMPLE

a(11)=15 since 11 is written in binary as 1011, which changes to 1111, i.e., 15; a(12)=8 since 12 is written as 1100 which changes to 1000, i.e., 8.

MATHEMATICA

bc[n_]:=Module[{idn2=IntegerDigits[n, 2]}, If[idn2[[2]]==1, idn2[[2]]=0, idn2[[2]]=1]; FromDigits[idn2, 2]]; Join[{0, 1}, Array[bc, 80, 2]] (* Harvey P. Dale, May 31 2012 *)

PROG

(PARI) a(n)=if(n<2, n>0, 3/2*2^floor(log(n)/log(2))-2^floor(log(4/3*n)/log(2))+n) /* Ralf Stephan */

(Python)

import math

def a(n): return n if n<2 else 3/2*2**int(math.floor(math.log(n)/math.log(2))) - 2**int(math.floor(math.log(4/3*n)/math.log(2))) + n # Indranil Ghosh, Mar 22 2017

(R)

maxrow <- 8 # by choice

b01 <- 1

for(m in 0:(maxrow-1)){

  b01 <- c(b01, rep(0, 2^(m+1))); b01[2^(m+1):(2^(m+1)+2^m-1)] <- 1

}

a <- c(1, 3, 2)

for(m in 0:(maxrow-2))

  for(k in 0:(2^m-1)){

    a[2^(m+2) +                 k] <- a[2^(m+1) + 2^m + k] + 2^((m+1) + b01[2^(m+2) +                 k])

    a[2^(m+2) +         + 2^m + k] <- a[2^(m+1) +       k] + 2^((m+1) + b01[2^(m+2) +         + 2^m + k])

    a[2^(m+2) + 2^(m+1) +       k] <- a[2^(m+1) + 2^m + k] + 2^((m+1) + b01[2^(m+2) + 2^(m+1) +       k])

    a[2^(m+2) + 2^(m+1) + 2^m + k] <- a[2^(m+1) +       k] + 2^((m+1) + b01[2^(m+2) + 2^(m+1) + 2^m + k])

}

a

# Yosu Yurramendi, Mar 30 2017

CROSSREFS

Cf. A004442, A053645, A054429.

Sequence in context: A276446 A100527 A276445 * A154441 A154446 A154442

Adjacent sequences:  A063943 A063944 A063945 * A063947 A063948 A063949

KEYWORD

easy,nonn,base

AUTHOR

Henry Bottomley, Sep 03 2001

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified February 19 16:38 EST 2019. Contains 320311 sequences. (Running on oeis4.)