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.

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

This page as a plain text file.
%I A180200 #70 Mar 21 2025 20:30:57
%S A180200 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 A180200 25,24,29,28,30,31,42,43,41,40,45,44,46,47,37,36,38,39,34,35,33,32,53,
%U A180200 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 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)).
%C A180200 Permutation of the natural numbers with inverse A180201;
%C A180200 A180198(n) = a(a(n));
%C A180200 a(A180199(n)) = A180199(a(n)) = A180201(n);
%C A180200 a(A075427(n)) = A075427(n).
%C A180200 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 A180200 Reinhard Zumkeller, <a href="/A180200/b180200.txt">Table of n, a(n) for n = 0..1023</a>
%H A180200 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A180200 a(n) = A258746(A233279(n)) = A233279(A117120(n)), n > 0. - _Yosu Yurramendi_, Apr 10 2017 [Corrected by _Yosu Yurramendi_, Mar 14 2025]
%F A180200 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 A180200 a(n) = A054429(A154435(n)) = A006068(A054429(n)), n > 0. - _Yosu Yurramendi_, Jun 05 2021
%p A180200 a:= proc(n) option remember; `if`(n<2, n, (m->
%p A180200       2*m+1-irem(m+n, 2))(a(iquo(n, 2))))
%p A180200     end:
%p A180200 seq(a(n), n=0..72);  # _Alois P. Heinz_, May 29 2021
%t A180200 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 A180200 (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 A180200 (Python)
%o A180200 def a(n):
%o A180200     if n<2:return n
%o A180200     else:
%o A180200         m=a(n//2)
%o A180200         return 2*m + 1 - (n%2 + m%2)%2 # _Indranil Ghosh_, Apr 05 2017
%o A180200 (C)
%o A180200 #include <stdio.h>
%o A180200 int a(int n){
%o A180200     int m;
%o A180200     if (n<2){return n;}
%o A180200     else{
%o A180200         m=a(n/2);
%o A180200         return 2*m  + 1 - (n%2 + m%2)%2;
%o A180200     }
%o A180200 }
%o A180200 int main()
%o A180200 {
%o A180200     int n=0;
%o A180200     for(; n<=100; n++)
%o A180200     printf("%d, ", a(n));
%o A180200     return 0;
%o A180200 } /* _Indranil Ghosh_, Apr 05 2017 */
%o A180200 (R)
%o A180200 maxn <- 63 # by choice
%o A180200 a <- 1
%o A180200 for(n in 1:maxn){
%o A180200 a[2*n  ] <- 2*a[n] + (a[n]%%2 == 0)
%o A180200 a[2*n+1] <- 2*a[n] + (a[n]%%2 != 0)}
%o A180200 a <- c(0,a)
%o A180200 # _Yosu Yurramendi_, May 23 2020
%Y A180200 Cf. A006068, A054429, A154435.
%K A180200 nonn,look
%O A180200 0,3
%A A180200 _Reinhard Zumkeller_, Aug 15 2010
%E A180200 Name edited by _Jon E. Schoenfield_, Apr 05 2017