login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A180200 a(0)=0, a(1)=1; for n > 1, a(n) = 2*m + 1 - (n mod 2 + m mod 2) mod 2, where m = a(floor(n/2)). 8
0, 1, 2, 3, 5, 4, 6, 7, 10, 11, 9, 8, 13, 12, 14, 15, 21, 20, 22, 23, 18, 19, 17, 16, 26, 27, 25, 24, 29, 28, 30, 31, 42, 43, 41, 40, 45, 44, 46, 47, 37, 36, 38, 39, 34, 35, 33, 32, 53, 52, 54, 55, 50, 51, 49, 48, 58, 59, 57, 56, 61, 60, 62, 63, 85, 84, 86, 87, 82, 83, 81, 80, 90 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

Permutation of the natural numbers with inverse A180201;

A180198(n) = a(a(n));

a(A180199(n)) = A180199(a(n)) = A180201(n);

a(A075427(n)) = A075427(n).

This permutation transforms the enumeration system of positive irreducible fractions A007305/A047679 (Stern-Brocot) into the enumeration system A245325/A245326, and enumeration system A162909/A162910 (Bird) into A071766/A229742 (HCS). - Yosu Yurramendi, Jun 09 2015

LINKS

R. Zumkeller, Table of n, a(n) for n = 0..1023

Index entries for sequences that are permutations of the natural numbers

FORMULA

a(n) = A233279(A258746(n)) = A117120(A233279(n)), n > 0. - Yosu Yurramendi, Apr 10 2017

MATHEMATICA

a[0] = 0; a[1] = 1; a[n_] := a[n] = 2 # + 1 - Mod[Mod[n, 2] + Mod[#, 2], 2] &@ a[Floor[n/2]]; Table[a@ n, {n, 0, 72}] (* Michael De Vlieger, Apr 02 2017 *)

PROG

(R)

  maxrow <- 8 # by choice

b01 <- 1

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

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

}

a <- 1:3

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)+    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)+2^m+k]+2^((m+1)+b01[2^(m+2)+2^(m+1)+2^m+k])

}

a

# Yosu Yurramendi, Mar 30 2017

(PARI) a(n) = if(n<2, n, my(m=a(n\2)); 2*m + 1 - (n%2 + m%2)%2); \\ Indranil Ghosh, Apr 05 2017

(Python)

def a(n):

....if n<2:return n

....else:

........m=a(n/2)

........return 2*m + 1 - (n%2 + m%2)%2 # Indranil Ghosh, Apr 05 2017

(C)

#include <stdio.h>

int a(int n){

    int m;

    if (n<2){return n; }

    else{

        m=a(n/2);

        return 2*m  + 1 - (n%2 + m%2)%2;

    }

}

int main()

{

    int n=0;

    for(; n<=100; n++)

    printf("%d, ", a(n));

    return 0;

} /* Indranil Ghosh, Apr 05 2017 */

CROSSREFS

Cf. A006068, A054429.

Sequence in context: A123917 A154444 A154443 * A121216 A132196 A153150

Adjacent sequences:  A180197 A180198 A180199 * A180201 A180202 A180203

KEYWORD

nonn,look

AUTHOR

Reinhard Zumkeller, Aug 15 2010

EXTENSIONS

Name edited by Jon E. Schoenfield, Apr 05 2017

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 March 29 18:26 EDT 2020. Contains 333116 sequences. (Running on oeis4.)