login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A341944 Next larger integer with same number of runs in binary expansion as n. 1
3, 4, 7, 6, 9, 8, 15, 12, 11, 18, 13, 14, 17, 16, 31, 24, 19, 20, 23, 22, 37, 26, 25, 28, 27, 34, 29, 30, 33, 32, 63, 48, 35, 36, 39, 38, 41, 40, 47, 44, 43, 74, 45, 46, 53, 50, 49, 56, 51, 52, 55, 54, 69, 58, 57, 60, 59, 66, 61, 62, 65, 64, 127, 96, 67, 68 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

Number of runs in binary expansion is given by A005811.

This is a permutation of A107907.

LINKS

Rémy Sigrist, Table of n, a(n) for n = 1..8191

Index entries for sequences related to binary expansion of n

FORMULA

A005811(a(n)) = A005811(n).

a(2^k-1) = 2^(k+1)-1 for any k > 0.

EXAMPLE

The first terms in decimal and in binary, alongside A005811(n), are:

  n   a(n)  bin(n)  bin(a(n))  A005811(n)

  --  ----  ------  ---------  ----------

   1     3       1         11           1

   2     4      10        100           2

   3     7      11        111           1

   4     6     100        110           2

   5     9     101       1001           3

   6     8     110       1000           2

   7    15     111       1111           1

   8    12    1000       1100           2

   9    11    1001       1011           3

  10    18    1010      10010           4

  11    13    1011       1101           3

  12    14    1100       1110           2

PROG

(PARI) a(n) = my (r=hammingweight(bitxor(n, n>>1))); for (k=n+1, oo, if (r==hammingweight(bitxor(k, k>>1)), return (k)))

(Python)

def runs(n): return bin(n^(n>>1)).count('1')

def a(n):

  nruns, m = runs(n), n + 1

  while runs(m) != nruns: m += 1

  return m

print([a(n) for n in range(1, 67)]) # Michael S. Branicky, Feb 24 2021

CROSSREFS

Cf. A000975, A005811, A057168, A107907.

Sequence in context: A215430 A096842 A147966 * A332994 A086469 A087030

Adjacent sequences:  A341941 A341942 A341943 * A341945 A341946 A341947

KEYWORD

nonn,base

AUTHOR

Rémy Sigrist, Feb 24 2021

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 11 12:47 EDT 2021. Contains 343791 sequences. (Running on oeis4.)