A271497 If n is a multiple of 3 then a(n) = n/3, otherwise a(n) = n'+n'', where n' (resp. n'') is obtained by sorting the bits of the binary expansion of n into increasing (resp. decreasing) order.
0, 2, 3, 1, 5, 9, 2, 14, 9, 3, 15, 21, 4, 21, 21, 5, 17, 27, 6, 35, 27, 7, 35, 45, 8, 35, 35, 9, 35, 45, 10, 62, 33, 11, 51, 63, 12, 63, 63, 13, 51, 63, 14, 75, 63, 15, 75, 93, 16, 63, 63, 17, 63, 75, 18, 93, 63, 19, 75, 93, 20, 93, 93, 21, 65, 99, 22, 119, 99, 23, 119, 135, 24, 119, 119, 25, 119, 135
Offset: 0
Examples
11 = 1011_2, so n' = 0111_2 = 7, n'' = 1110_2 = 14, and therefore a(11) = 7+14 = 21.
Links
- Chai Wah Wu, Table of n, a(n) for n = 0..10000
Programs
-
Maple
A271497:=proc(n) local t1,t2,len; global b; if n mod (b+1) = 0 then return(n/(b+1)); fi; t1:=convert(n,base,b); len:=nops(t1); t2:=sort(t1); add(t2[i]*(b^(i-1)+b^(len-i)),i=1..len); end; b:=2; [seq(A271497(n),n=0..100)];
-
Python
from _future_ import division def A271497(n): return int(''.join(sorted(bin(n)[2:])),2) + int(''.join(sorted(bin(n)[2:],reverse=True)),2) if n % 3 else n//3 # Chai Wah Wu, Apr 16 2016