login
The OEIS is supported by the many generous donors to the OEIS 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)). 13

%I #54 Jun 20 2021 22:13:07

%S 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,

%T 25,24,29,28,30,31,42,43,41,40,45,44,46,47,37,36,38,39,34,35,33,32,53,

%U 52,54,55,50,51,49,48,58,59,57,56,61,60,62,63,85,84,86,87,82,83,81,80,90

%N 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)).

%C Permutation of the natural numbers with inverse A180201;

%C A180198(n) = a(a(n));

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

%C a(A075427(n)) = A075427(n).

%C 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

%H Reinhard Zumkeller, <a href="/A180200/b180200.txt">Table of n, a(n) for n = 0..1023</a>

%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>

%F a(n) = A233279(A258746(n)) = A117120(A233279(n)), n > 0. - _Yosu Yurramendi_, Apr 10 2017

%F a(0) = 0, a(1) = 1, for n > 0 a(2*n) = 2*a(n) + [a(n) even], a(2*n + 1) = 2*a(n) + [a(n) odd]. - _Yosu Yurramendi_, May 23 2020

%F a(n) = A054429(A154435(n)) = A006068(A054429(n)), n > 0. - _Yosu Yurramendi_, Jun 05 2021

%p a:= proc(n) option remember; `if`(n<2, n, (m->

%p 2*m+1-irem(m+n, 2))(a(iquo(n, 2))))

%p end:

%p seq(a(n), n=0..72); # _Alois P. Heinz_, May 29 2021

%t 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 *)

%o (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

%o (Python)

%o def a(n):

%o ....if n<2:return n

%o ....else:

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

%o ........return 2*m + 1 - (n%2 + m%2)%2 # _Indranil Ghosh_, Apr 05 2017

%o (C)

%o #include <stdio.h>

%o int a(int n){

%o int m;

%o if (n<2){return n;}

%o else{

%o m=a(n/2);

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

%o }

%o }

%o int main()

%o {

%o int n=0;

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

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

%o return 0;

%o } /* _Indranil Ghosh_, Apr 05 2017 */

%o (R)

%o maxn <- 63 # by choice

%o a <- 1

%o for(n in 1:maxn){

%o a[2*n ] <- 2*a[n] + (a[n]%%2 == 0)

%o a[2*n+1] <- 2*a[n] + (a[n]%%2 != 0)}

%o a <- c(0,a)

%o # _Yosu Yurramendi_, May 23 2020

%Y Cf. A006068, A054429, A154435.

%K nonn,look

%O 0,3

%A _Reinhard Zumkeller_, Aug 15 2010

%E Name edited by _Jon E. Schoenfield_, Apr 05 2017

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 13:16 EDT 2024. Contains 371950 sequences. (Running on oeis4.)