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.

A258996 Permutation of the positive integers: this permutation transforms the enumeration system of positive irreducible fractions A002487/A002487' (Calkin-Wilf) into the enumeration system A162911/A162912 (Drib), and vice versa.

This page as a plain text file.
%I A258996 #68 Mar 18 2025 19:01:10
%S A258996 1,2,3,6,7,4,5,10,11,8,9,14,15,12,13,26,27,24,25,30,31,28,29,18,19,16,
%T A258996 17,22,23,20,21,42,43,40,41,46,47,44,45,34,35,32,33,38,39,36,37,58,59,
%U A258996 56,57,62,63,60,61,50,51,48,49,54,55,52,53
%N A258996 Permutation of the positive integers: this permutation transforms the enumeration system of positive irreducible fractions A002487/A002487' (Calkin-Wilf) into the enumeration system A162911/A162912 (Drib), and vice versa.
%C A258996 As A258746 the permutation is self-inverse. Except for fixed points 1, 2, 3 it consists completely of 2-cycles: (4,6), (5,7), (8,10), (9,11), (12,14), (13,15), (16,26), (17,27), ..., (21,31), ..., (32,42), ... . - _Yosu Yurramendi_, Mar 31 2016
%C A258996 When terms of sequence |n - a(n)|/2 (n > 3) are considered only once, and they are sorted in increasing order, A147992 is obtained. - _Yosu Yurramendi_, Apr 05 2016
%H A258996 Yosu Yurramendi, <a href="/A258996/b258996.txt">Table of n, a(n) for n = 1..16383</a>
%H A258996 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F A258996 a(1) = 1, a(2) = 2, a(3) = 3. For n = 2^m + k, m > 1, 0 <= k < 2^m. If m is even, then a(2^(m+1)+k) = a(2^m + k) + 2^m and a(2^(m+1) + 2^m+k) = a(2^m+k) + 2^(m+1). If m is odd, then a(2^(m+1) + k) = a(2^m+k) + 2^(m+1) and a(2^(m+1) + 2^m+k) = a(2^m+k) + 2^m.
%F A258996 From _Yosu Yurramendi_, Mar 23 2017: (Start)
%F A258996 A258746(a(n)) = a(A258746(n)), n > 0.
%F A258996 A092569(a(n)) = a(A092569(n)), n > 0.
%F A258996 A117120(a(n)) = a(A117120(n)), n > 0;
%F A258996 A065190(a(n)) = a(A065190(n)), n > 0;
%F A258996 A054429(a(n)) = a(A054429(n)), n > 0;
%F A258996 A063946(a(n)) = a(A063946(n)), n > 0. (End)
%F A258996 a(1) = 1, for m >= 0  and 0 <= k < 2^m, a(2^(m+1) + 2*k) = 2*a(2^(m+1) - 1 - k), a(2^(m+1) + 2*k + 1) = 2*a(2^(m+1) - 1 - k) + 1. - _Yosu Yurramendi_, May 23 2020
%F A258996 a(n) = A020988(A102572(n)) XOR n. - _Alan Michael Gómez Calderón_, Mar 11 2025
%o A258996 (R)
%o A258996 maxlevel <- 5 # by choice
%o A258996 a <- 1
%o A258996 for(m in 0:maxlevel) for(k in 0:(2^m-1)){
%o A258996   a[2^(m+1) + 2*k    ] = 2*a[2^(m+1) - 1 - k]
%o A258996   a[2^(m+1) + 2*k + 1] = 2*a[2^(m+1) - 1 - k] + 1}
%o A258996 a
%o A258996 (R) # Given n, compute a(n) by taking into account the binary representation of n
%o A258996 maxblock <- 7 # by choice
%o A258996 a <- 1:3
%o A258996 for(n in 4:2^maxblock){
%o A258996   ones <- which(as.integer(intToBits(n)) == 1)
%o A258996   nbit <- as.integer(intToBits(n))[1:tail(ones, n = 1)]
%o A258996   anbit <- nbit
%o A258996   anbit[seq(2, length(anbit) - 1, 2)] <- 1 - anbit[seq(2, length(anbit) - 1, 2)]
%o A258996   a <- c(a, sum(anbit*2^(0:(length(anbit) - 1))))
%o A258996 }
%o A258996 a
%o A258996 # _Yosu Yurramendi_, Mar 30 2021
%Y A258996 Cf. A092569, A117120, A258746. Similar R-programs: A332769, A284447.
%K A258996 nonn,look
%O A258996 1,2
%A A258996 _Yosu Yurramendi_, Jun 16 2015