A116361 Smallest k such that n XOR n*2^k = n*(2^k + 1).
0, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 4, 2, 4, 3, 4, 1, 1, 1, 2, 1, 1, 4, 5, 2, 2, 4, 5, 3, 5, 4, 5, 1, 1, 1, 2, 1, 1, 2, 6, 1, 1, 1, 6, 4, 4, 5, 6, 2, 2, 2, 2, 4, 6, 5, 6, 3, 6, 5, 6, 4, 6, 5, 6, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 4, 2, 5, 6, 7, 1, 1, 1, 7, 1, 1, 6, 7, 4, 5, 4, 7, 5, 5, 6, 7, 2, 2, 2, 2, 2, 7, 2, 7, 4
Offset: 0
Links
- Charles R Greathouse IV, Table of n, a(n) for n = 0..10000
Programs
-
Mathematica
a[n_] := Module[{k}, For[k = 0, True, k++, If[BitXor[n, n*2^k] == n*(2^k+1), Return[k]]]]; Table[a[n], {n, 0, 104}] (* Jean-François Alcover, Nov 19 2021 *)
-
PARI
a(n)=my(k);while(bitxor(n,n<
Charles R Greathouse IV, Mar 07 2013 -
Python
from itertools import count def A116361(n): return next(k for k in count(0) if n^(m:=n<
Chai Wah Wu, Jul 19 2024
Extensions
Offset corrected by Charles R Greathouse IV, Mar 07 2013
Comments