A038585 Write n in binary, delete 0's.
1, 1, 11, 1, 11, 11, 111, 1, 11, 11, 111, 11, 111, 111, 1111, 1, 11, 11, 111, 11, 111, 111, 1111, 11, 111, 111, 1111, 111, 1111, 1111, 11111, 1, 11, 11, 111, 11, 111, 111, 1111, 11, 111, 111, 1111, 111, 1111, 1111, 11111, 11, 111, 111, 1111, 111, 1111, 1111
Offset: 1
Links
Programs
-
Haskell
a038585 0 = 0 a038585 n = (9 * m + 1) * (a038585 n') + m where (n', m) = divMod n 2 -- Reinhard Zumkeller, Oct 10 2012
-
Mathematica
Table[FromDigits[DeleteCases[IntegerDigits[n,2],?(#==0&)]],{n,60}] (* _Harvey P. Dale, Feb 27 2012 *) FromDigits/@(IntegerDigits[Range[60],2]/.(0->Nothing)) (* Harvey P. Dale, Apr 09 2017 *)
-
Python
def A038585(n): return int(bin(n)[2:].replace('0','')) # Chai Wah Wu, May 19 2020
Formula
a(n) = (9 * n mod 2 + 1) * a(floor(n/2)) + n mod 2. - Reinhard Zumkeller, Oct 10 2012
Extensions
More terms from Erich Friedman