login
Next larger integer with same number of runs of 1's in its binary representation as n.
1

%I #8 Feb 25 2019 08:25:22

%S 2,3,4,6,9,7,8,12,10,11,13,14,17,15,16,24,18,19,20,22,37,23,25,28,26,

%T 27,29,30,33,31,32,48,34,35,36,38,41,39,40,44,42,43,45,46,53,47,49,56,

%U 50,51,52,54,69,55,57,60,58,59,61,62,65,63,64,96,66,67,68

%N Next larger integer with same number of runs of 1's in its binary representation as n.

%C Number of runs of 1's in binary representation is given by A069010.

%C Each nonnegative number either appears in this sequence or in A002450.

%F a(A023758(n)) = A023758(n+1) for any n > 1.

%F a(A043682(n)) = A043682(n+1) for any n > 0.

%F a(A043683(n)) = A043683(n+1) for any n > 0.

%F a(A043684(n)) = A043684(n+1) for any n > 0.

%F a(A043685(n)) = A043685(n+1) for any n > 0.

%F a(A043686(n)) = A043686(n+1) for any n > 0.

%e The first terms, in decimal and in binary, are:

%e n a(n) bin(n) bin(a(n))

%e -- ---- ------ ---------

%e 1 2 1 10

%e 2 3 10 11

%e 3 4 11 100

%e 4 6 100 110

%e 5 9 101 1001

%e 6 7 110 111

%e 7 8 111 1000

%e 8 12 1000 1100

%e 9 10 1001 1010

%e 10 11 1010 1011

%e 11 13 1011 1101

%e 12 14 1100 1110

%e 13 17 1101 10001

%e 14 15 1110 1111

%e 15 16 1111 10000

%e 16 24 10000 11000

%o (PARI) r1(n) = my (c=0); while (n, my (v=valuation(n+(n%2),2)); if (n%2, c++); n\=2^v); c

%o a(n) = my (r=r1(n)); for (k=n+1, oo, if (r==r1(k), return (k)))

%Y Cf. A002450, A023758, A043682, A043683, A043684, A043685, A043686, A057168, A069010.

%K nonn,base

%O 1,1

%A _Rémy Sigrist_, Feb 15 2019