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!)
A161822 a(n) = the smallest positive integer such that both n and a(n), when represented in binary, contain the same types of runs of 0's, the runs being in any order. 5

%I #16 Feb 02 2018 02:36:33

%S 1,2,1,4,2,2,1,8,4,10,2,4,2,2,1,16,8,18,4,18,10,10,2,8,4,10,2,4,2,2,1,

%T 32,16,34,8,36,18,18,4,34,18,42,10,18,10,10,2,16,8,18,4,18,10,10,2,8,

%U 4,10,2,4,2,2,1,64,32,66,16,68,34,34,8,68,36,74,18,36,18,18,4,66,34,74,18

%N a(n) = the smallest positive integer such that both n and a(n), when represented in binary, contain the same types of runs of 0's, the runs being in any order.

%C Clarification of definition: Think of binary n and a(n) each as a string of 0's and 1's. Consider the "runs" of 0's in binary n and a(n), where each run is made up completely of 0's, and is bounded on both sides either by 1's or by the edge of the string. Now consider the lengths of each bounded run of 0's (the number of 0's in each run). Then a(n) is the smallest positive integer whose set of run-lengths is a permutation of the set of run-lengths for n. (See example.)

%C 1 <= a(n) <= n. a(n) = n iff n = 2^m for some m. a(n) = 1 iff n = 2^m - 1 for some m. - _Hagen von Eitzen_, Jun 22 2009

%H Michael De Vlieger, <a href="/A161822/b161822.txt">Table of n, a(n) for n = 1..10000</a>

%e 84 in binary is 1010100. There are three runs of 0's, two runs of one 0 each and one run of two 0's. So we are looking for the smallest positive integer with two runs of one 0 each and one run of two 0's (and no other runs of 0's). For example, 16 in binary is 10000, which contains the runs, except that it is required that each run be bounded by 1's or the edge of the binary string. The next number that fits the requirements completely is 74 = 1001010 in binary. So a(84) = 74.

%t f[n_] := Sort@ Map[Length, Select[Split@ IntegerDigits[n, 2], First@ # == 0 &]]; Table[Block[{k = 1}, While[f@ k != f@ n, k++]; k], {n, 83}] (* _Michael De Vlieger_, Aug 31 2017 *)

%o (PARI) a(n)=local(B=binary(n),L=[],ct=0);forstep(i=#B,1,-1,if(B[i],if(ct,L=concat(L,ct);ct=0),ct++)); L=vecsort(L);forstep(i=#L,1,-1,ct=(ct*2+1)*2^L[i]);if(ct>0,ct,1) \\ _Hagen von Eitzen_, Jun 22 2009

%Y Cf. A161819, A161820, A161821.

%K base,nonn

%O 1,2

%A _Leroy Quet_, Jun 20 2009

%E More terms from _Hagen von Eitzen_, Jun 22 2009

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 April 24 00:30 EDT 2024. Contains 371917 sequences. (Running on oeis4.)