A082008 a(n) = A082007(n-1) + 1.
1, 2, 3, 4, 7, 10, 13, 5, 6, 8, 9, 11, 12, 14, 15, 16, 31, 46, 61, 76, 91, 106, 121, 136, 151, 166, 181, 196, 211, 226, 241, 17, 18, 32, 33, 47, 48, 62, 63, 77, 78, 92, 93, 107, 108, 122, 123, 137, 138, 152, 153, 167, 168, 182, 183, 197, 198
Offset: 1
Links
- Ivan Neretin, Table of n, a(n) for n = 1..8191
- Steve Witham, Clumpy Heapsort.
Programs
-
Mathematica
w = {{1}}; Do[k = 2^Floor@Log2[n - 1]; AppendTo[w, Flatten@Table[w[[n - k]] + (2^k - 1) i, {i, 2^k}]], {n, 2, 7}]; a = Flatten@w (* Ivan Neretin, Mar 12 2017 *)
-
Python
def A082008( n ): if n == 1: return 1 y = 2 ** int( log( n, 2 ) ) yc = 2 ** 2 ** int( log( log( y, 2 ), 2 ) ) yr = y // yc return (yc-1) * int( (n-y) / yr + 1 ) + A082008( yr + n % yr ) # Steve Witham (sw(AT)tiac.net), Oct 13 2009
Extensions
The origin is 1 Steve Witham (sw(AT)tiac.net), Oct 13 2009
Comments