A140690 A positive integer n is included if n written in binary can be subdivided into a number of runs all of equal-length, the first run from the left consisting of all 1's, the next run consisting of all 0's, the next run consisting of all 1's, the next run consisting of all 0's, etc.
1, 2, 3, 5, 7, 10, 12, 15, 21, 31, 42, 51, 56, 63, 85, 127, 170, 204, 240, 255, 341, 455, 511, 682, 819, 992, 1023, 1365, 2047, 2730, 3276, 3640, 3855, 4032, 4095, 5461, 8191, 10922, 13107, 16256, 16383, 21845, 29127, 31775, 32767, 43690, 52428, 61680
Offset: 1
Examples
819 in binary is 1100110011. The runs of 0's and 1's are (11)(00)(11)(00)(11). Each run (alternating 1's and 0's) is the same length. So 819 is in the sequence.
Links
Programs
-
Haskell
import Data.Set (singleton, deleteFindMin, insert) a140690 n = a140690_list !! (n-1) a140690_list = f $ singleton (1, 1, 2) where f s | k == 1 = m : f (insert (2*b-1, 1, 2*b) $ insert (b*m, k+1, b) s') | even k = m : f (insert (b*m+b-1, k+1, b) s') | otherwise = m : f (insert (b*m, k+1, b) s') where ((m, k, b), s') = deleteFindMin s -- Reinhard Zumkeller, Feb 21 2014
-
Maple
Runs := proc (L) local j, r, i, k: j := 1: r[j] := L[1]: for i from 2 to nops(L) do if L[i] = L[i-1] then r[j] := r[j], L[i] else j := j+1: r[j] := L[i] end if end do: [seq([r[k]], k = 1 .. j)] end proc: RunLengths := proc (L) map(nops, Runs(L)) end proc: c := proc (n) ListTools:-Reverse(convert(n, base, 2)): RunLengths(%) end proc: A := {}: for n to 62000 do if nops(convert(c(n), set)) = 1 then A := `union`(A, {n}) else end if end do: A; # most of the Maple program is due to W. Edwin Clark. - Emeric Deutsch, Jan 25 2018
-
Mathematica
Select[Range[62000],Length[Union[Length/@Split[IntegerDigits[#,2]]]]==1&] (* Harvey P. Dale, Mar 22 2012 *)
Extensions
Terms beyond 42 from R. J. Mathar, Aug 04 2008
Comments