The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A153151 Rotated binary decrementing: For n<2 a(n) = n, if n=2^k, a(n) = 2*n-1, otherwise a(n) = n-1. 8

%I #43 Jan 13 2024 10:12:06

%S 0,1,3,2,7,4,5,6,15,8,9,10,11,12,13,14,31,16,17,18,19,20,21,22,23,24,

%T 25,26,27,28,29,30,63,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,

%U 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,127,64,65,66,67,68,69

%N Rotated binary decrementing: For n<2 a(n) = n, if n=2^k, a(n) = 2*n-1, otherwise a(n) = n-1.

%C Without the initial 0, a(n) is the lexicographically minimal sequence of distinct positive integers such that all values of a(n) mod n are distinct and nonnegative. - _Ivan Neretin_, Apr 27 2015

%C A002487(n)/A002487(n+1), n > 0, runs through all the reduced nonnegative rationals exactly once. A002487 is the Stern's sequence. Permutation from denominators (A002487(n+1))

%C 1 2 1 3 2 3 1 4 3 5 2 5 3 4 1

%C where labels are

%C 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

%C to numerators (A002487(n))

%C 1 1 2 1 3 2 3 1 4 3 5 2 5 3 4

%C where changed labels are

%C 1 3 2 7 4 5 6 15 8 9 10 11 12 13 14

%C Thus, b(n) = A002487(n+1), b(a(n)) = A002487(n), n>0. - _Yosu Yurramendi_, Jul 07 2016

%H A. Karttunen, <a href="/A153151/b153151.txt">Table of n, a(n) for n = 0..2047</a>

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

%F a(n) = A059893(A153141(A059893(n))) = A059894(A153142(A059894(n))).

%p a := n -> if n < 2 then n elif convert(convert(n, base, 2), `+`) = 1 then 2*n-1 else n-1 fi: seq(a(n), n=0..70); # _Peter Luschny_, Jul 16 2016

%t Table[Which[n < 2, n, IntegerQ[Log[2, n]], 2 n - 1, True, n - 1], {n, 0, 70}] (* _Michael De Vlieger_, Apr 27 2015 *)

%o (MIT/GNU Scheme) (define (A153151 n) (cond ((< n 2) n) ((pow2? n) (- (* 2 n) 1)) (else (- n 1))))

%o (define (pow2? n) (and (> n 0) (zero? (A004198bi n (- n 1)))))

%o (Python)

%o def ok(n): return n&(n - 1)==0

%o def a(n): return n if n<2 else 2*n - 1 if ok(n) else n - 1 # _Indranil Ghosh_, Jun 09 2017

%o (R)

%o nmax <- 126 # by choice

%o a <- c(1,3,2)

%o for(n in 3:nmax) a[n+1] <- n

%o for(m in 0:floor(log2(nmax))) a[2^m] <- 2^(m+1) - 1

%o a <- c(0, a)

%o # _Yosu Yurramendi_, Sep 05 2020

%Y Inverse: A153152.

%Y Cf. A059893, A059894, A153141, A153142.

%K nonn,base

%O 0,3

%A _Antti Karttunen_, Dec 20 2008

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 May 20 16:51 EDT 2024. Contains 372719 sequences. (Running on oeis4.)