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.
%I A080541 #51 May 13 2025 11:34:32 %S A080541 1,2,3,4,6,5,7,8,10,12,14,9,11,13,15,16,18,20,22,24,26,28,30,17,19,21, %T A080541 23,25,27,29,31,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,33,35, %U A080541 37,39,41,43,45,47,49,51,53,55,57,59,61,63,64,66,68,70,72,74,76,78,80 %N A080541 In binary representation: keep the first digit and left-rotate the others. %C A080541 Permutation of natural numbers: let r(n,0)=n, r(n,k)=a(r(n,k-1)) for k>0, then r(n,floor(log_2(n))) = n and for n>1: r(n,floor(log_2(n))-1) = A080542(n). %C A080541 Discarding their most significant bit, binary representations of numbers present in each cycle of this permutation form a distinct equivalence class of binary necklaces, thus there are A000031(n) separate cycles in each range [2^n .. (2^(n+1))-1] (for n >= 0) of this permutation. A256999 gives the largest number present in n's cycle. - _Antti Karttunen_, May 16 2015 %H A080541 Antti Karttunen, <a href="/A080541/b080541.txt">Table of n, a(n) for n = 1..8192</a> %H A080541 <a href="/index/Ne#necklaces">Index entries for sequences related to necklaces</a> %H A080541 <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a> %F A080541 From _Antti Karttunen_, May 16 2015: (Start) %F A080541 a(1) = 1; for n > 1, a(n) = A053644(n) bitwise_OR (2*A053645(n) + second_most_significant_bit_of(n)). [Here bitwise_OR is a 2-argument function given by array A003986 and second_most_significant_bit_of gives the second most significant bit (0 or 1) of n larger than 1. See A079944.] %F A080541 Other identities. For all n >= 1: %F A080541 a(n) = A059893(A080542(A059893(n))). %F A080541 a(n) = A054429(a(A054429(n))). %F A080541 (End) %F A080541 A080542(a(n)) = a(A080542(n)) = n. [A080542 is the inverse permutation.] %F A080541 From _Robert Israel_, May 19 2015: (Start) %F A080541 Let d = floor(log[2](n)). If n >= 3*2^(d-1) then a(n) = 2*n + 1 - 2^(d+1), otherwise a(n) = 2*n - 2^d. %F A080541 G.f.: 2*x/(x-1)^2 + Sum_{n>=1} x^(2^n)+(2^n-1)*x^(3*2^(n-1)))/(x-1). (End) %e A080541 a(20)=a('10100')='11000'=24; a(24)=a('11000')='10001'=17. %p A080541 f:= proc(n) local d; %p A080541 d:= ilog2(n); %p A080541 if n >= 3/2*2^d then 2*n+1-2^(d+1) else 2*n - 2^d fi %p A080541 end proc: %p A080541 map(f, [$1..100]); # _Robert Israel_, May 19 2015 %t A080541 A080541[n_] := FromDigits[Join[{First[#]}, RotateLeft[Rest[#]]], 2] & [IntegerDigits[n, 2]]; %t A080541 Array[A080541, 100] (* _Paolo Xausa_, May 13 2025 *) %o A080541 (Scheme) %o A080541 (define (A080541 n) (if (< n 2) n (A003986bi (A053644 n) (+ (* 2 (A053645 n)) (A079944off2 n))))) ;; A003986bi gives the bitwise OR of its two arguments. See A003986. %o A080541 ;; Where A079944off2 gives the second most significant bit of n. (Cf. A079944): %o A080541 (define (A079944off2 n) (A000035 (floor->exact (/ n (A072376 n))))) %o A080541 ;; _Antti Karttunen_, May 16 2015 %o A080541 (R) %o A080541 maxlevel <- 6 # by choice %o A080541 a <- 1:3 %o A080541 for(m in 1:maxlevel) for(k in 0:(2^(m-1)-1)){ %o A080541 a[2^(m+1) + 2*k ] = 2*a[2^m + k] %o A080541 a[2^(m+1) + 2*k + 1] = 2*a[2^m + 2^(m-1) + k] %o A080541 a[2^(m+1) + 2^m + 2*k ] = 2*a[2^m + k] + 1 %o A080541 a[2^(m+1) + 2^m + 2*k + 1] = 2*a[2^m + 2^(m-1) + k] + 1 %o A080541 } %o A080541 a %o A080541 # _Yosu Yurramendi_, Oct 12 2020 %o A080541 (Python) %o A080541 def A080541(n): return ((n&(m:=1<<n.bit_length()-2)-1)<<1)+(m<<1)+bool(m&n) if n > 1 else n # _Chai Wah Wu_, Jan 22 2023 %Y A080541 Inverse: A080542. %Y A080541 Cf. A000031, A003986, A053644, A053645, A000523, A007088, A079944, A080413, A080543, A054429, A256999, A257250. %Y A080541 The set of permutations {A059893, A080541, A080542} generates an infinite dihedral group. %K A080541 nonn,base %O A080541 1,2 %A A080541 _Reinhard Zumkeller_, Feb 20 2003