login
This site is supported by donations to The OEIS Foundation.
Logo

Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A057168 Next larger integer with same binary weight (number of 1 bits) as n. 3
2, 4, 5, 8, 6, 9, 11, 16, 10, 12, 13, 17, 14, 19, 23, 32, 18, 20, 21, 24, 22, 25, 27, 33, 26, 28, 29, 35, 30, 39, 47, 64, 34, 36, 37, 40, 38, 41, 43, 48, 42, 44, 45, 49, 46, 51, 55, 65, 50, 52, 53, 56, 54, 57, 59, 67, 58, 60, 61, 71, 62, 79, 95, 128, 66, 68, 69, 72, 70, 73, 75 (list; graph; refs; listen; history; internal format)
OFFSET

1,1

COMMENTS

Binary weight is given by A000120.

a(A000079(n))=A000079(n+1); a(A000051(n))=A052548(n); a(A052548(n))=A140504(n); a(A000225(n))=A055010(n); (A007283(n))=A000051(n+2). [From Reinhard Zumkeller (reinhard.zumkeller(AT)gmail.com), Aug 18 2008]

a(n) = MIN{m: A000120(m)=A000120(n) and m>n}. [From Reinhard Zumkeller (reinhard.zumkeller(AT)gmail.com), Aug 15 2009]

REFERENCES

Beeler, M., Gosper, R. W. and Schroeppel, R. HAKMEM. MIT AI Memo 239, Feb. 29, 1972 (Item 175).

Donald Knuth, The Art of Computer Programming, Vol. 4A, section 7.1.3, exercises 20-21.

LINKS

R. Zumkeller, Table of n, a(n) for n = 1..10000 [From Reinhard Zumkeller (reinhard.zumkeller(AT)gmail.com), Aug 15 2009]

Beeler, M., Gosper, R. W. and Schroeppel, R., HAKMEM ITEM 175

EXAMPLE

a(6)=9 since 6 has two one-bits (i.e. 6=2+4) and 9 is the next higher integer of binary weight two (7 is weight three and 8 is weight one).

MATHEMATICA

a[n_] := (bw = DigitCount[n, 2, 1]; k = n+1; While[ DigitCount[k, 2, 1] != bw, k++]; k); Table[a[n], {n, 1, 71}](* From Jean-François Alcover, Nov 28 2011 *)

PROG

(PARI) a(n)={my(u=bitand(n, -n), v=u+n); (bitxor(v, n)/u)>>2+v};

CROSSREFS

Cf. A000120, A006519, A057169.

Sequence in context: A101410 A110991 A076990 * A087711 A123128 A057064

Adjacent sequences:  A057165 A057166 A057167 * A057169 A057170 A057171

KEYWORD

easy,nonn,nice

AUTHOR

Marc LeBrun (mlb(AT)well.com), Sep 14 2000

EXTENSIONS

Program and reference from Charles R Greathouse IV (charles.greathouse(AT)case.edu), Oct 28 2009

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
Recent Additions | More pages | Superseeker | Maintained by The OEIS Foundation Inc.

Content is available under The OEIS End-User License Agreement .

Last modified February 15 23:53 EST 2012. Contains 205860 sequences.