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

%I #13 Mar 02 2019 23:11:58

%S 2,4,6,8,9,12,14,16,10,17,13,24,19,28,30,32,18,20,22,33,37,25,29,48,

%T 26,35,51,56,39,60,62,64,34,36,38,40,41,44,46,65,42,69,45,49,53,57,61,

%U 96,50,52,54,67,75,99,59,112,58,71,103,120,79,124,126,128,66,68,70,72,73

%N a(n) = the smallest integer > n such that both n and a(n), when represented in binary, contain the same types of runs of 1'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 1's in binary n and a(n), where each run is made up completely of 1's, and is bounded on both sides either by 0's or by the edge of the string. Now consider the lengths of each bounded run of 1's (the number of 1's in each run). Then a(n) is the smallest integer greater than n whose set of run-lengths is a permutation of the set of run-lengths for n. (See example.)

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

%e 77 in binary is 1001101. There are three runs of 1's, two runs of one 1 each and one run of two 1's. So we are looking for the smallest integer > 77 with two runs of one 1 each and one run of two 1's (and no other runs of 1's). For example, 78 in binary is 1001110, which contains the runs, except that it is required that each run be bounded by 0's or the edge of the binary string. The next number that fits the requirements completely is 83 = 1010011 in binary. So a(77) = 83.

%p rtype := proc(n) local rt, bdgs,pr,i,rl ; rt := [seq(0,i=1..40)] ; bdgs := convert(n,base,2) ; pr := 0 ; for i from 1 to nops(bdgs) do if op(i,bdgs) = 1 then if pr = 0 then rl := 0 ; fi; rl := rl+1 ; else if pr = 1 then rt := subsop(rl=op(rl,rt)+1,rt) ; fi; fi; pr := op(i,bdgs) ; if i = nops(bdgs) and pr = 1 then rt := subsop(rl=op(rl,rt)+1,rt) ; fi; od: rt ; end: A161819 := proc(n) local rtn,a; rtn := rtype(n) ; for a from n+1 do if rtype(a) = rtn then RETURN(a) ; fi; od: end: seq(A161819(n),n=1..100) ; # _R. J. Mathar_, Jul 20 2009

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

%Y Cf. A161820, A161821, A161822.

%K base,nonn

%O 1,1

%A _Leroy Quet_, Jun 20 2009

%E More terms from _R. J. Mathar_, Jul 20 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 25 03:15 EDT 2024. Contains 371964 sequences. (Running on oeis4.)