A080541 In binary representation: keep the first digit and left-rotate the others.
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, 23, 25, 27, 29, 31, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 64, 66, 68, 70, 72, 74, 76, 78, 80
Offset: 1
Examples
a(20)=a('10100')='11000'=24; a(24)=a('11000')='10001'=17.
Links
Crossrefs
Programs
-
Maple
f:= proc(n) local d; d:= ilog2(n); if n >= 3/2*2^d then 2*n+1-2^(d+1) else 2*n - 2^d fi end proc: map(f, [$1..100]); # Robert Israel, May 19 2015
-
Mathematica
A080541[n_] := FromDigits[Join[{First[#]}, RotateLeft[Rest[#]]], 2] & [IntegerDigits[n, 2]]; Array[A080541, 100] (* Paolo Xausa, May 13 2025 *)
-
Python
def A080541(n): return ((n&(m:=1<
1 else n # Chai Wah Wu, Jan 22 2023 -
R
maxlevel <- 6 # by choice a <- 1:3 for(m in 1:maxlevel) for(k in 0:(2^(m-1)-1)){ a[2^(m+1) + 2*k ] = 2*a[2^m + k] a[2^(m+1) + 2*k + 1] = 2*a[2^m + 2^(m-1) + k] a[2^(m+1) + 2^m + 2*k ] = 2*a[2^m + k] + 1 a[2^(m+1) + 2^m + 2*k + 1] = 2*a[2^m + 2^(m-1) + k] + 1 } a # Yosu Yurramendi, Oct 12 2020
-
Scheme
(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. ;; Where A079944off2 gives the second most significant bit of n. (Cf. A079944): (define (A079944off2 n) (A000035 (floor->exact (/ n (A072376 n))))) ;; Antti Karttunen, May 16 2015
Formula
From Antti Karttunen, May 16 2015: (Start)
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.]
Other identities. For all n >= 1:
(End)
From Robert Israel, May 19 2015: (Start)
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.
G.f.: 2*x/(x-1)^2 + Sum_{n>=1} x^(2^n)+(2^n-1)*x^(3*2^(n-1)))/(x-1). (End)
Comments